gh workflow #32
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Internal sync PR | |
| on: | |
| push: | |
| branches: | |
| - slice/internal # every push to this branch triggers the job | |
| permissions: # required for the built-in token from 2024-08 onwards | |
| contents: write # create/update branches | |
| pull-requests: write # open/update PRs | |
| jobs: | |
| open-pr: | |
| runs-on: ubuntu-latest | |
| concurrency: # never run two of these at once | |
| group: pr-slice-internal | |
| cancel-in-progress: true | |
| env: | |
| GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} # gh picks this up automatically | |
| steps: | |
| - uses: actions/checkout@v4 | |
| with: {fetch-depth: 0} # full history, just in case | |
| - name: Ensure PR exists | |
| run: | | |
| set -euo pipefail | |
| # Does an open PR from slice/internal -> main already exist? | |
| pr_number=$(gh pr list \ | |
| --head slice/internal \ | |
| --base main \ | |
| --state open \ | |
| --json number \ | |
| --jq '.[0].number' || true) | |
| if [[ -z "$pr_number" ]]; then | |
| echo "No open PR found – creating one." | |
| gh pr create \ | |
| --head slice/internal \ | |
| --base main \ | |
| --title "Sync slice/internal → main" \ | |
| --body "Automated PR – triggered by commit $GITHUB_SHA" | |
| else | |
| echo "PR #$pr_number already exists – nothing to do." | |
| fi |