mirror of
https://github.com/TheBeastLT/torrentio-scraper.git
synced 2026-05-16 17:11:52 +00:00
70 lines
2.2 KiB
YAML
70 lines
2.2 KiB
YAML
name: Build and Push Docker Image
|
|
|
|
on:
|
|
push:
|
|
branches: master
|
|
paths:
|
|
- 'addon/**'
|
|
- '.github/**'
|
|
|
|
env:
|
|
IMAGE_NAME: torrentio-addon
|
|
|
|
jobs:
|
|
build-and-push:
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
- name: Checkout code
|
|
uses: actions/checkout@v3
|
|
|
|
- name: Set up Docker Buildx
|
|
uses: docker/setup-buildx-action@v2
|
|
|
|
- name: Set credential variables
|
|
id: credentials
|
|
run: |
|
|
echo "DOCKER_USERNAME=$(echo ${DOCKER_USERNAME:-${{ secrets.DOCKER_USERNAME }} })" >> $GITHUB_OUTPUT
|
|
echo "DOCKER_PASSWORD=$(echo ${DOCKER_PASSWORD:-${{ secrets.DOCKER_PASSWORD }}:-${{ secrets.DOCKER_TOKEN }}:-${{ env.DOCKER_TOKEN }} })" >> $GITHUB_OUTPUT
|
|
if [ -n "$(echo ${DOCKER_USERNAME:-${{ secrets.DOCKER_USERNAME }} })" ]; then
|
|
echo "HAS_DOCKER_CREDS=true" >> $GITHUB_OUTPUT
|
|
else
|
|
echo "HAS_DOCKER_CREDS=false" >> $GITHUB_OUTPUT
|
|
fi
|
|
|
|
- name: Docker metadata
|
|
id: meta
|
|
uses: docker/metadata-action@v4
|
|
with:
|
|
images: |
|
|
${{ steps.credentials.outputs.DOCKER_USERNAME != '' && format('{0}/{1}', steps.credentials.outputs.DOCKER_USERNAME, env.IMAGE_NAME) || '' }}
|
|
ghcr.io/${{ github.repository_owner }}/${{ env.IMAGE_NAME }}
|
|
tags: |
|
|
type=raw,value=latest
|
|
type=sha,format=short
|
|
|
|
- name: Login to DockerHub
|
|
if: steps.credentials.outputs.HAS_DOCKER_CREDS == 'true'
|
|
uses: docker/login-action@v2
|
|
with:
|
|
username: ${{ steps.credentials.outputs.DOCKER_USERNAME }}
|
|
password: ${{ steps.credentials.outputs.DOCKER_PASSWORD }}
|
|
continue-on-error: true
|
|
|
|
- name: Login to GitHub Container Registry
|
|
uses: docker/login-action@v2
|
|
with:
|
|
registry: ghcr.io
|
|
username: ${{ github.repository_owner }}
|
|
password: ${{ github.token }}
|
|
continue-on-error: true
|
|
|
|
- name: Build and push
|
|
uses: docker/build-push-action@v4
|
|
with:
|
|
context: ./addon/
|
|
push: true
|
|
tags: ${{ steps.meta.outputs.tags }}
|
|
labels: ${{ steps.meta.outputs.labels }}
|
|
cache-from: type=gha
|
|
cache-to: type=gha,mode=max
|