mirror of
https://github.com/pypa/gh-action-pypi-publish.git
synced 2024-11-25 10:01:02 -05:00
Check repo owner ID instead of repo name
This commit is contained in:
parent
a360fcb184
commit
f51682fb52
2 changed files with 9 additions and 3 deletions
|
@ -113,14 +113,17 @@ runs:
|
||||||
# https://github.com/actions/runner/issues/2473
|
# https://github.com/actions/runner/issues/2473
|
||||||
REF=${{ env.ACTION_REF || env.PR_REF || github.ref_name }}
|
REF=${{ env.ACTION_REF || env.PR_REF || github.ref_name }}
|
||||||
REPO=${{ env.ACTION_REPO || env.PR_REPO || github.repository }}
|
REPO=${{ env.ACTION_REPO || env.PR_REPO || github.repository }}
|
||||||
|
REPO_OWNER_ID=${{ env.PR_REPO_OWNER_ID || github.repository_owner_id }}
|
||||||
echo "ref=$REF" >>"$GITHUB_OUTPUT"
|
echo "ref=$REF" >>"$GITHUB_OUTPUT"
|
||||||
echo "repo=$REPO" >>"$GITHUB_OUTPUT"
|
echo "repo=$REPO" >>"$GITHUB_OUTPUT"
|
||||||
|
echo "repo-owner-id=$REPO_OWNER_ID" >>"$GITHUB_OUTPUT"
|
||||||
shell: bash
|
shell: bash
|
||||||
env:
|
env:
|
||||||
ACTION_REF: ${{ github.action_ref }}
|
ACTION_REF: ${{ github.action_ref }}
|
||||||
ACTION_REPO: ${{ github.action_repository }}
|
ACTION_REPO: ${{ github.action_repository }}
|
||||||
PR_REF: ${{ github.event.pull_request.head.ref }}
|
PR_REF: ${{ github.event.pull_request.head.ref }}
|
||||||
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
PR_REPO: ${{ github.event.pull_request.head.repo.full_name }}
|
||||||
|
PR_REPO_OWNER_ID: ${{ github.event.pull_request.base.repo.owner.id }}
|
||||||
- name: Check out action repo
|
- name: Check out action repo
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
with:
|
with:
|
||||||
|
@ -135,6 +138,7 @@ runs:
|
||||||
EVENT: ${{ github.event_name }}
|
EVENT: ${{ github.event_name }}
|
||||||
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
|
REF: ${{ steps.set-repo-and-ref.outputs.ref }}
|
||||||
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
|
REPO: ${{ steps.set-repo-and-ref.outputs.repo }}
|
||||||
|
REPO_OWNER_ID: ${{ steps.set-repo-and-ref.outputs.repo-owner-id }}
|
||||||
shell: bash
|
shell: bash
|
||||||
working-directory: action-repo
|
working-directory: action-repo
|
||||||
- name: Run Docker container
|
- name: Run Docker container
|
||||||
|
|
|
@ -8,16 +8,18 @@ REQUIRED = 'required'
|
||||||
EVENT = os.environ['EVENT']
|
EVENT = os.environ['EVENT']
|
||||||
REF = os.environ['REF']
|
REF = os.environ['REF']
|
||||||
REPO = os.environ['REPO']
|
REPO = os.environ['REPO']
|
||||||
|
REPO_OWNER_ID = os.environ['REPO_OWNER_ID']
|
||||||
|
REPO_OWNER_ID_PYPA = '647025'
|
||||||
|
|
||||||
|
|
||||||
def set_image(event: str, ref: str, repo: str) -> str:
|
def set_image(event: str, ref: str, repo: str, repo_owner_id: str) -> str:
|
||||||
if event == 'pull_request' and 'gh-action-pypi-publish' in repo:
|
if event == 'pull_request' and repo_owner_id == REPO_OWNER_ID_PYPA:
|
||||||
return '../../../Dockerfile'
|
return '../../../Dockerfile'
|
||||||
docker_ref = ref.replace('/', '-')
|
docker_ref = ref.replace('/', '-')
|
||||||
return f'docker://ghcr.io/{repo}:{docker_ref}'
|
return f'docker://ghcr.io/{repo}:{docker_ref}'
|
||||||
|
|
||||||
|
|
||||||
image = set_image(EVENT, REF, REPO)
|
image = set_image(EVENT, REF, REPO, REPO_OWNER_ID)
|
||||||
|
|
||||||
action = {
|
action = {
|
||||||
'name': '🏃',
|
'name': '🏃',
|
||||||
|
|
Loading…
Reference in a new issue