Skip to content

Commit 6fdf59b

Browse files
vahid-ahmadiclaude
andauthored
Replace personal PAT with GITHUB_TOKEN in versioning workflow (#1530)
The Versioning job previously required secrets.POLICYENGINE_GITHUB (a personal PAT) to push the version bump commit and re-trigger the Publish job. This broke when the PAT expired. Changes: - Use GITHUB_TOKEN with contents:write for same-repo checkout/push - Restructure Publish as needs:Versioning sequential job instead of relying on a re-triggered push event (GITHUB_TOKEN pushes don't trigger new workflow runs) - Make cross-repo update_api.py conditional on POLICYENGINE_GITHUB secret availability Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 10ac428 commit 6fdf59b

2 files changed

Lines changed: 15 additions & 5 deletions

File tree

.github/workflows/versioning.yaml

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
# Workflow that runs on versioning metadata updates.
2+
# Uses GITHUB_TOKEN (not a personal PAT) for same-repo operations.
3+
# Cross-repo API updates require POLICYENGINE_GITHUB secret (org-level PAT).
24

35
name: Versioning updates
46
on:
@@ -11,16 +13,20 @@ on:
1113
- pyproject.toml
1214
workflow_dispatch:
1315

16+
permissions:
17+
contents: write
18+
1419
jobs:
1520
Versioning:
1621
runs-on: ubuntu-latest
1722
if: |
1823
(!(github.event.head_commit.message == 'Update package version'))
24+
outputs:
25+
committed: ${{ steps.commit.outputs.committed }}
1926
steps:
2027
- name: Checkout repo
2128
uses: actions/checkout@v4
2229
with:
23-
token: ${{ secrets.POLICYENGINE_GITHUB }}
2430
fetch-depth: 0
2531
- name: Install uv
2632
uses: astral-sh/setup-uv@v5
@@ -35,18 +41,20 @@ jobs:
3541
python .github/bump_version.py
3642
towncrier build --yes --version $(python -c "import re; print(re.search(r'version = \"(.+?)\"', open('pyproject.toml').read()).group(1))")
3743
- name: Update changelog
44+
id: commit
3845
uses: EndBug/add-and-commit@v9
3946
with:
4047
add: "."
4148
message: Update package version
4249
Publish:
4350
runs-on: ubuntu-latest
44-
if: (github.event.head_commit.message == 'Update package version')
45-
env:
46-
GH_TOKEN: ${{ secrets.POLICYENGINE_GITHUB }}
51+
needs: Versioning
52+
if: needs.Versioning.outputs.committed == 'true'
4753
steps:
4854
- name: Checkout repo
4955
uses: actions/checkout@v4
56+
with:
57+
ref: main
5058
- name: Install uv
5159
uses: astral-sh/setup-uv@v5
5260

@@ -71,6 +79,7 @@ jobs:
7179
password: ${{ secrets.PYPI }}
7280
skip_existing: true
7381
- name: Update API
82+
if: ${{ secrets.POLICYENGINE_GITHUB != '' }}
7483
run: python .github/update_api.py
7584
env:
76-
GITHUB_TOKEN: ${{ secrets.POLICYENGINE_GITHUB }}
85+
GITHUB_TOKEN: ${{ secrets.POLICYENGINE_GITHUB }}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Replaced personal PAT with `GITHUB_TOKEN` in versioning workflow. Publish now runs as a sequential job instead of requiring a re-triggered workflow, removing the dependency on a personal access token for same-repo operations.

0 commit comments

Comments
 (0)