From befcb293207689124278af8dc3ff2f7691de3f52 Mon Sep 17 00:00:00 2001 From: Max Ghenis Date: Fri, 17 Apr 2026 19:40:36 -0400 Subject: [PATCH] Mint GitHub App token in push workflow Replace the expired POLICYENGINE_GITHUB org PAT with a GitHub App token minted at job start via actions/create-github-app-token@v1. The App (APP_ID / APP_PRIVATE_KEY) is already installed on this repo and is the long-term auth path used by sibling repos (core, microdf, us, ng, canada, it). - versioning job: app-token feeds checkout and EndBug/add-and-commit (fetch: false so the action doesn't try to re-fetch with a stale ref) - Deploy job: app-token feeds checkout and update_api.py env (GH_TOKEN + GITHUB_TOKEN) Co-Authored-By: Claude Opus 4.7 (1M context) --- .github/workflows/push.yaml | 23 ++++++++++++++++----- changelog.d/migrate-to-app-token.changed.md | 1 + 2 files changed, 19 insertions(+), 5 deletions(-) create mode 100644 changelog.d/migrate-to-app-token.changed.md diff --git a/.github/workflows/push.yaml b/.github/workflows/push.yaml index 36eca00..17613d2 100644 --- a/.github/workflows/push.yaml +++ b/.github/workflows/push.yaml @@ -15,10 +15,16 @@ jobs: && !(github.event.head_commit.message == 'Update PolicyEngine Israel') runs-on: ubuntu-latest steps: + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} - name: Checkout repo uses: actions/checkout@v4 with: - token: ${{ secrets.POLICYENGINE_GITHUB }} + token: ${{ steps.app-token.outputs.token }} - name: Setup Python uses: actions/setup-python@v5 with: @@ -37,6 +43,8 @@ jobs: committer_name: Github Actions[bot] author_name: Github Actions[bot] message: Update PolicyEngine Israel + github_token: ${{ steps.app-token.outputs.token }} + fetch: false Test: runs-on: ${{ matrix.os }} if: | @@ -95,13 +103,17 @@ jobs: (github.repository == 'PolicyEngine/policyengine-il') && (github.event.head_commit.message == 'Update PolicyEngine Israel') runs-on: ubuntu-latest - env: - GH_TOKEN: ${{ secrets.POLICYENGINE_GITHUB }} steps: + - name: Generate GitHub App token + id: app-token + uses: actions/create-github-app-token@v1 + with: + app-id: ${{ secrets.APP_ID }} + private-key: ${{ secrets.APP_PRIVATE_KEY }} - name: Checkout repo uses: actions/checkout@v4 with: - token: ${{ secrets.POLICYENGINE_GITHUB }} + token: ${{ steps.app-token.outputs.token }} - name: Setup Python uses: actions/setup-python@v5 with: @@ -113,4 +125,5 @@ jobs: - name: Update API run: python .github/update_api.py env: - GITHUB_TOKEN: ${{ secrets.POLICYENGINE_GITHUB }} + GH_TOKEN: ${{ steps.app-token.outputs.token }} + GITHUB_TOKEN: ${{ steps.app-token.outputs.token }} diff --git a/changelog.d/migrate-to-app-token.changed.md b/changelog.d/migrate-to-app-token.changed.md new file mode 100644 index 0000000..1501f62 --- /dev/null +++ b/changelog.d/migrate-to-app-token.changed.md @@ -0,0 +1 @@ +Mint GitHub App token at runtime in push workflow instead of using the expired org PAT.