diff --git a/.github/workflows/deploy_docker_ghcr.yml b/.github/workflows/deploy_docker_ghcr.yml new file mode 100644 index 0000000..d410b12 --- /dev/null +++ b/.github/workflows/deploy_docker_ghcr.yml @@ -0,0 +1,59 @@ +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: Docker metadata + id: meta + uses: docker/metadata-action@v4 + with: + images: | + ${{ secrets.DOCKER_USERNAME || env.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: ${{ secrets.DOCKER_USERNAME || env.DOCKER_USERNAME }} + uses: docker/login-action@v2 + with: + username: ${{ secrets.DOCKER_USERNAME || env.DOCKER_USERNAME }} + password: ${{ secrets.DOCKER_PASSWORD || env.DOCKER_PASSWORD || secrets.DOCKER_TOKEN || env.DOCKER_TOKEN }} + continue-on-error: true + + - name: Login to GitHub Container Registry + uses: docker/login-action@v2 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN || 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