From 449911d90ff523f4846b4ec2f486b15615a5b2dc Mon Sep 17 00:00:00 2001 From: anonymous-org-za Date: Mon, 8 Jul 2024 09:25:27 +0000 Subject: [PATCH] ci: updates docker to use ghcr as well as automated tags --- .github/workflows/docker-build.yml | 37 ++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/.github/workflows/docker-build.yml b/.github/workflows/docker-build.yml index 22786c2..09796dc 100644 --- a/.github/workflows/docker-build.yml +++ b/.github/workflows/docker-build.yml @@ -2,11 +2,32 @@ name: docker-build on: push: + branches: + - "**" + tags: + - "v*.*.*" + pull_request: jobs: docker: runs-on: ubuntu-latest steps: + - name: Docker meta + id: meta + uses: docker/metadata-action@v5 + with: + # list of Docker images to use as base name for tags + images: | + anonymoussystems/torbox-tinfoil-server + ghcr.io/anonymous-org-za/torbox-tinfoil-server + # generate Docker tags based on the following events/attributes + tags: | + type=ref,event=branch + type=ref,event=pr + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=semver,pattern={{major}} + type=sha - name: Set up QEMU uses: docker/setup-qemu-action@v3 @@ -15,13 +36,21 @@ jobs: uses: docker/setup-buildx-action@v3 - name: Login to Docker Hub + if: github.event_name != 'pull_request' uses: docker/login-action@v3 with: username: ${{ secrets.DOCKERHUB_USERNAME }} password: ${{ secrets.DOCKERHUB_TOKEN }} - - - name: Build and push + - name: Login to GHCR + if: github.event_name != 'pull_request' + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Build and push uses: docker/build-push-action@v6 with: - push: true - tags: anonymoussystems/torbox-tinfoil-server:latest \ No newline at end of file + push: ${{ github.event_name != 'pull_request' }} + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file