Skip to content

Commit

Permalink
Better support publishing container images from forked repos (wayfair…
Browse files Browse the repository at this point in the history
…-incubator#161)

Allow setting target container registry with a repo scoped variable
  • Loading branch information
Oded-B authored Apr 5, 2024
1 parent 1508139 commit ec59f1d
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 4 deletions.
8 changes: 6 additions & 2 deletions .github/workflows/docker-publish-on-comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,10 @@ on:
types: [created]


env:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
REGISTRY: ${{ vars.REGISTRY }}

jobs:
build:
Expand Down Expand Up @@ -54,10 +58,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log into Docker Hub registry
if: secrets.DOCKERHUB_TOKEN != ''
if: env.DOCKERHUB_USERNAME != ''
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
Expand Down
8 changes: 6 additions & 2 deletions .github/workflows/docker-publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ on:
pull_request:
branches: [ "main" ]

env:
DOCKERHUB_USERNAME: ${{ vars.DOCKERHUB_USERNAME }}
IMAGE_NAME: ${{ vars.IMAGE_NAME }}
REGISTRY: ${{ vars.REGISTRY }}

jobs:
build:
Expand Down Expand Up @@ -56,10 +60,10 @@ jobs:
password: ${{ secrets.GITHUB_TOKEN }}

- name: Log into Docker Hub registry
if: github.event_name != 'pull_request' && secrets.DOCKERHUB_TOKEN != ''
if: github.event_name != 'pull_request' && env.DOCKERHUB_USERNAME != ''
uses: docker/login-action@3d58c274f17dffee475a5520cbe67f0a882c4dbb
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
username: ${{ env.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

# Extract metadata (tags, labels) for Docker
Expand Down
8 changes: 8 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,14 @@ See [here](docs/observability.md)
* Add a webhook to repo setting (don't forget the `/webhook` path in the URL).
* Content type needs to be `application/json`, **currently** only PR events are needed

To publish container images from a forked repo set the `IMAGE_NAME` and `REGISTRY` GitHub Action Repository variables to use GitHub packages.
`REGISTRY` should be `ghcr.io` and `IMAGE_NAME` should match the repository slug, like so:
like so:
<img width="785" alt="image" src="https://github.com/commercetools/telefonistka/assets/1616153/2f7201d6-fdb2-4cbf-8705-d6da7f4f6e80">




## Roadmap

See the [open issues](https://github.com/wayfair-incubator/telefonistka/issues) for a list of proposed features (and known issues).
Expand Down

0 comments on commit ec59f1d

Please sign in to comment.