From 150813986450c1d9f88f58245ba1e8318bed511c Mon Sep 17 00:00:00 2001 From: Oded Ben Ozer Date: Wed, 3 Apr 2024 17:09:36 +0200 Subject: [PATCH] Make image publish more flexible by moving image name and registery to (#160) "repo settings" --- .github/workflows/docker-publish-on-comment.yml | 13 ++++--------- .github/workflows/docker-publish.yml | 17 +++++------------ 2 files changed, 9 insertions(+), 21 deletions(-) diff --git a/.github/workflows/docker-publish-on-comment.yml b/.github/workflows/docker-publish-on-comment.yml index 52c4c418..4763d08c 100644 --- a/.github/workflows/docker-publish-on-comment.yml +++ b/.github/workflows/docker-publish-on-comment.yml @@ -9,11 +9,6 @@ on: issue_comment: types: [created] -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} jobs: @@ -51,14 +46,15 @@ jobs: # Login against a Docker registry except on PR # https://github.com/docker/login-action - - name: Log into GH registry ${{ env.REGISTRY }} + - name: Log into GH registry (ghcr.io) uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Log into Docker Hub registry ${{ env.REGISTRY }} + - name: Log into Docker Hub registry + if: secrets.DOCKERHUB_TOKEN != '' uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -75,7 +71,6 @@ jobs: context: git images: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - odedbenozer/telefonistka tags: | type=ref,event=branch type=ref,event=pr diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml index 853797a5..cb3e3c72 100644 --- a/.github/workflows/docker-publish.yml +++ b/.github/workflows/docker-publish.yml @@ -15,12 +15,6 @@ on: pull_request: branches: [ "main" ] -env: - # Use docker.io for Docker Hub if empty - REGISTRY: ghcr.io - # github.repository as / - IMAGE_NAME: ${{ github.repository }} - jobs: build: @@ -53,16 +47,16 @@ jobs: # Login against a Docker registry except on PR # https://github.com/docker/login-action - - name: Log into GH registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' + - name: Log into GH registry (ghcr.io) + if: github.event_name != 'pull_request' uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb with: - registry: ${{ env.REGISTRY }} + registry: ghcr.io username: ${{ github.actor }} password: ${{ secrets.GITHUB_TOKEN }} - - name: Log into Docker Hub registry ${{ env.REGISTRY }} - if: github.event_name != 'pull_request' + - name: Log into Docker Hub registry + if: github.event_name != 'pull_request' && secrets.DOCKERHUB_TOKEN != '' uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb with: username: ${{ secrets.DOCKERHUB_USERNAME }} @@ -78,7 +72,6 @@ jobs: with: images: | ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} - odedbenozer/telefonistka # Build and push Docker image with Buildx (don't push on PR)