Skip to content

Commit e79329a

Browse files
Merge pull request #39 from moduon/ci-build-on-prs
ci: run build-test-push on all PRs, not just same-repo
2 parents 6c0a19c + 85f46b5 commit e79329a

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

.github/workflows/ci.yaml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525
- uses: pre-commit/action@v1.0.1
2626

2727
build-test-push:
28-
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository)
28+
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) || github.event_name == 'pull_request'
2929
runs-on: ubuntu-latest
3030
needs: pre-commit
3131
permissions:
@@ -62,6 +62,8 @@ jobs:
6262
# Github does not allow evaluating a secret in an if condition, so we need to set them as environment variables
6363
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
6464
DOCKERHUB_LOGIN: ${{ secrets.DOCKERHUB_LOGIN }}
65+
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
66+
BOT_LOGIN: ${{ secrets.BOT_LOGIN }}
6567
steps:
6668
# Image repo names have to be lowercase.
6769
- name: Lowercase image repository name
@@ -98,8 +100,9 @@ jobs:
98100
REGISTRY_USERNAME: ${{ env.DOCKERHUB_LOGIN }}
99101
run: ./hooks/push
100102
- name: Push Docker Image to GitHub Registry
103+
if: github.event_name != 'pull_request' || github.event.pull_request.head.repo.full_name == github.repository || env.BOT_TOKEN && env.BOT_LOGIN
101104
env:
102105
REGISTRY_HOST: ghcr.io
103-
REGISTRY_TOKEN: ${{ secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
104-
REGISTRY_USERNAME: ${{ secrets.BOT_LOGIN || github.repository_owner }}
106+
REGISTRY_TOKEN: ${{ secrets.BOT_LOGIN && secrets.BOT_TOKEN || secrets.GITHUB_TOKEN }}
107+
REGISTRY_USERNAME: ${{ secrets.BOT_TOKEN && secrets.BOT_LOGIN || github.repository_owner }}
105108
run: ./hooks/push

0 commit comments

Comments
 (0)