Skip to content

Commit

Permalink
docker: don't push on a Pull Request (#1767)
Browse files Browse the repository at this point in the history
* docker: don't push on a Pull Request

Since the github action triggers on a PR too, `github.ref` will be the target
branch for merging (typically `develop`). In that case, don't try to login/push
to docker hub.

https://docs.github.com/en/actions/learn-github-actions/contexts#github-context

Signed-off-by: Дамјан Георгиевски <[email protected]>

* Create 1767.bugfix

* check if env.PUSH is the "true" string

Signed-off-by: Дамјан Георгиевски <[email protected]>

---------

Signed-off-by: Дамјан Георгиевски <[email protected]>
Co-authored-by: Will Hunt <[email protected]>
  • Loading branch information
gdamjan and Half-Shot authored Aug 8, 2023
1 parent 8953058 commit 4163275
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
7 changes: 4 additions & 3 deletions .github/workflows/docker-hub-latest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ env:
DOCKER_NAMESPACE: matrixdotorg
PLATFORMS: linux/amd64
# Only push if this is develop, otherwise we just want to build
PUSH: ${{ github.ref == 'refs/heads/develop' }}
# On a PR github.ref is the target branch, so don't push for that either
PUSH: ${{ github.ref == 'refs/heads/develop' && github.event_name != 'pull_request' }}

jobs:
docker-latest:
Expand All @@ -21,7 +22,7 @@ jobs:
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
if: ${{ env.PUSH }}
if: ${{ env.PUSH == 'true' }}
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_TOKEN }}
Expand All @@ -34,4 +35,4 @@ jobs:
platforms: ${{ env.PLATFORMS }}
push: ${{ env.PUSH }}
tags: |
${{ env.DOCKER_NAMESPACE }}/matrix-appservice-irc:latest
${{ env.DOCKER_NAMESPACE }}/matrix-appservice-irc:latest
1 change: 1 addition & 0 deletions changelog.d/1767.bugfix
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Fix GitHub CI docker builds failing for community PRs.

0 comments on commit 4163275

Please sign in to comment.