Repository navigation
gh-actions: push image to GHCR on internal PRs - #581
Conversation
This makes it easier to test changes in a development environment before they are merged. Bug: T446336
| name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v4.6.0 | ||
| if: github.event_name != 'pull_request' | ||
| # Don't run this step if the PR was created by Dependabot or from a forked repository |
There was a problem hiding this comment.
Do we really need this comment? The code is clear enough for me tho
There was a problem hiding this comment.
I think it is beneficial.
It is not super obvious to me exactly which repository github.event.pull_request.head.repo.full_name and github.repository refer to. Is it the target repo (wbstack) or the source repo (e.g. wbstack or addshore).
It's also not immediately obvious why github.event.pull_request.head.repo.full_name == github.repository is included in the conditional. Having this comment adds that we don't want to do these steps on forked repositories.
Unless you think the comment is wrong, let's leave it in for this PR. If people want to update or delete it they can create another PR and we can discuss it there. 🙂
There was a problem hiding this comment.
FYI, I would really like to get this merged ASAP so that it is easier to test the MediaWiki image built for T446155 locally before it has been merged into main.
| cache-to: type=local,mode=max,dest=/tmp/.buildx-cache | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| # Don't push the image if the PR was created by Dependabot or from a forked repository | ||
| push: ${{ github.actor != 'dependabot[bot]' && github.event.pull_request.head.repo.full_name == github.repository }} |
There was a problem hiding this comment.
@tarrow asked in the daily if github.event.pull_request.head.repo.full_name == github.repository was necessary, thinking that the image would be pushed to the container registry of the pull request source repository owner.
In the current setup, this step is always pushing to the pull request target repository owner's GHCR.
You can see by looking at the Docker meta step of this docker.build.yml workflow of external PR#573 that the tags in the JSON output is set to ["ghcr.io/wbstack/mediawiki:sha-439ecd7"] which is what the Build and push step uses.
I believe that github.repository_owner, which is the current value of the username of the Login to GitHub Container Registry step, is the owner of the repository where the workflow is running (i.e. wbstack).
The workflow permissions includes Packages: read so even if username of the Login to GitHub Container Registry step was set to the pull request source repository owner, I don't think the permissions exist for it to succeed.
| name: Login to GitHub Container Registry | ||
| uses: docker/login-action@v4.6.0 | ||
| if: github.event_name != 'pull_request' | ||
| # Don't run this step if the PR was created by Dependabot or from a forked repository |
There was a problem hiding this comment.
I think it is beneficial.
It is not super obvious to me exactly which repository github.event.pull_request.head.repo.full_name and github.repository refer to. Is it the target repo (wbstack) or the source repo (e.g. wbstack or addshore).
It's also not immediately obvious why github.event.pull_request.head.repo.full_name == github.repository is included in the conditional. Having this comment adds that we don't want to do these steps on forked repositories.
Unless you think the comment is wrong, let's leave it in for this PR. If people want to update or delete it they can create another PR and we can discuss it there. 🙂
This makes it easier to test changes in a development environment before they are merged.
Bug: T446336