Skip to content

Commit

Permalink
Add GH_REPO to jobs with gh calls (pantsbuild#19477)
Browse files Browse the repository at this point in the history
This change adds `GH_REPO: ${{ github.repository }}` env variables to
all jobs which calls `gh`. Although not strictly necessary if the job
checks out the repo, setting it universally is more robust and is easy.
  • Loading branch information
thejcannon authored Jul 16, 2023
1 parent b92bc2e commit 1228d70
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 3 deletions.
6 changes: 6 additions & 0 deletions .github/workflows/release.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ jobs:
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
Expand Down Expand Up @@ -133,6 +134,7 @@ jobs:
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
Expand Down Expand Up @@ -205,6 +207,7 @@ jobs:
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
Expand Down Expand Up @@ -277,6 +280,7 @@ jobs:
name: Deploy wheels to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
if: needs.release_info.outputs.is-release == 'true'
name: Upload Pants PEX
Expand Down Expand Up @@ -354,6 +358,7 @@ jobs:
name: Deploy commit mapping to S3
run: ./pants run src/python/pants_release/deploy_to_s3.py -- --scope tags/pantsbuild.pants
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
name: Publish GitHub Release
run: 'gh release upload ${{ needs.release_info.outputs.build-ref }} dest/pypi_release
Expand All @@ -377,6 +382,7 @@ jobs:
\nfi\necho \"build-ref=${ref}\" >> $GITHUB_OUTPUT\nif [[ \"${ref}\" =~ ^release_.+$\
\ ]]; then\n echo \"is-release=true\" >> $GITHUB_OUTPUT\nfi\n"
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ github.token }}
if: github.repository_owner == 'pantsbuild' && steps.get_info.outputs.is-release
== 'true'
Expand Down
15 changes: 12 additions & 3 deletions src/python/pants_release/generate_github_workflows.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,10 @@ def build_wheels_job(
{
"name": "Upload Pants PEX",
"if": "needs.release_info.outputs.is-release == 'true'",
"env": {"GH_TOKEN": "${{ github.token }}"},
"env": {
"GH_TOKEN": "${{ github.token }}",
"GH_REPO": "${{ github.repository }}",
},
"run": dedent(
"""\
LOCAL_TAG=$(PEX_INTERPRETER=1 dist/src.python.pants/pants-pex.pex -c "import sys;major, minor = sys.version_info[:2];import os;uname = os.uname();print(f'cp{major}{minor}-{uname.sysname.lower()}_{uname.machine.lower()}')")
Expand Down Expand Up @@ -1065,7 +1068,10 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]:
{
"name": "Make GitHub Release",
"if": f"{IS_PANTS_OWNER} && steps.get_info.outputs.is-release == 'true'",
"env": {"GH_TOKEN": "${{ github.token }}"},
"env": {
"GH_TOKEN": "${{ github.token }}",
"GH_REPO": "${{ github.repository }}",
},
"run": dedent(
"""\
RELEASE_TAG=${{ steps.get_info.outputs.build-ref }}
Expand Down Expand Up @@ -1178,7 +1184,10 @@ def release_jobs_and_inputs() -> tuple[Jobs, dict[str, Any]]:
),
{
"name": "Publish GitHub Release",
"env": {"GH_TOKEN": "${{ github.token }}"},
"env": {
"GH_TOKEN": "${{ github.token }}",
"GH_REPO": "${{ github.repository }}",
},
"run": dedent(
f"""\
gh release upload {gha_expr("needs.release_info.outputs.build-ref") } {pypi_release_dir}
Expand Down

0 comments on commit 1228d70

Please sign in to comment.