Skip to content

Commit

Permalink
Make image publish more flexible by moving image name and registery to (
Browse files Browse the repository at this point in the history
#160)

"repo settings"
  • Loading branch information
Oded-B authored Apr 3, 2024
1 parent c19c518 commit 1508139
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 21 deletions.
13 changes: 4 additions & 9 deletions .github/workflows/docker-publish-on-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,6 @@ on:
issue_comment:
types: [created]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
Expand Down Expand Up @@ -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 }}
Expand All @@ -75,7 +71,6 @@ jobs:
context: git
images: |
${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}
odedbenozer/telefonistka
tags: |
type=ref,event=branch
type=ref,event=pr
Expand Down
17 changes: 5 additions & 12 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ on:
pull_request:
branches: [ "main" ]

env:
# Use docker.io for Docker Hub if empty
REGISTRY: ghcr.io
# github.repository as <account>/<repo>
IMAGE_NAME: ${{ github.repository }}


jobs:
build:
Expand Down Expand Up @@ -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 }}
Expand All @@ -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)
Expand Down

0 comments on commit 1508139

Please sign in to comment.