Behaviour
Currently, metadata-action
creates tags like pr-XXX
when used in a GitHub Action triggered by the pull_request
event. This means when using pull requests inside a repository you can publish "preview" docker images which can then be inspected / tested by other GitHub Actions or the pull request reviewers.
However, when a pull request is sent from a forked repository (such as when groups are using the "fork and pull" model), the pull_request
event does not have access to things like the secrets nor write access -- this means that you can't push these pr-XXX
tags.
To solve this issue, GitHub created the pull_request_target
event, which runs on pull requests using the workflow configuration from the primary repository (see https://github.blog/2020-08-03-github-actions-improvements-for-fork-and-pull-request-workflows/ and https://docs.github.com/en/actions/reference/events-that-trigger-workflows#pull_request_target).
However, when using the pull_request_target
the metadata-action
instead generates a tag of the upstream branch name. Instead it should generate the same style of tags as pull_request
.
Steps to reproduce this issue
- Use
metadata-action
in a GitHub Action triggered by pull_request_target
.
Expected behaviour
Create tags based on the pull request number like pr-XXX
.
Actual behaviour
Create tags based on the upstream branch name.
Configuration
- Repository URL (if public):
- Build URL (if public):
on:
pull_request:
pull_request_target:
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Docker meta
id: docker_meta
uses: docker/metadata-action@v3
with:
tags: |
type=ref,event=tag
type=ref,event=pr
type=ref,event=branch
type=sha
type=sha,format=long
Logs
pull_request
example
Context info
eventName: pull_request_target
sha: 7e536a20216d13ae89e82f4f0040889c53062158
ref: refs/heads/upstream-main
workflow: Build Docker Image for Run DRC for cell GDS (using Magic) Action
action: dockermetadata-action
actor: mithro
runNumber: 40
runId: 867571226
Processing tags input
type=ref,event=tag,enable=true,priority=600
type=ref,event=pr,prefix=pr-,enable=true,priority=600
type=ref,event=branch,enable=true,priority=600
type=sha,prefix=sha-,format=short,enable=true,priority=100
type=sha,format=long,prefix=sha-,enable=true,priority=100
Processing flavor input
latest=auto
prefix=
suffix=
Docker image version
upstream-main
Docker tags
localhost:5000/run-drc-for-cell-gds-using-magic:upstream-main
localhost:5000/run-drc-for-cell-gds-using-magic:sha-7e536a2
localhost:5000/run-drc-for-cell-gds-using-magic:sha-7e536a20216d13ae89e82f4f0040889c53062158
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:upstream-main
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-7e536a2
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-7e536a20216d13ae89e82f4f0040889c53062158
pull_request_target
example
Context info
eventName: pull_request
sha: 5427096b63e64959becdba7da5a713a69205bc11
ref: refs/pull/4/merge
workflow: Build Docker Image for Run DRC for cell GDS (using Magic) Action
action: dockermetadata-action
actor: mithro
runNumber: 36
runId: 867535443
Processing tags input
type=ref,event=tag,enable=true,priority=600
type=ref,event=pr,prefix=pr-,enable=true,priority=600
type=ref,event=branch,enable=true,priority=600
type=sha,prefix=sha-,format=short,enable=true,priority=100
type=sha,format=long,prefix=sha-,enable=true,priority=100
Processing flavor input
Docker image version
pr-4
Docker tags
localhost:5000/run-drc-for-cell-gds-using-magic:pr-4
localhost:5000/run-drc-for-cell-gds-using-magic:sha-5427096
localhost:5000/run-drc-for-cell-gds-using-magic:sha-5427096b63e64959becdba7da5a713a69205bc11
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:pr-4
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-5427096
gcr.io/skywater-pdk/actions/run-drc-for-cell-gds-using-magic:sha-5427096b63e64959becdba7da5a713a69205bc11