@@ -10,66 +10,36 @@ permissions: # required for the built-in token from 2024-08 onwa
1010 pull-requests : write # open/update PRs
1111
1212jobs :
13- create-or-update -pr :
13+ open -pr :
1414 runs-on : ubuntu-latest
15-
15+ concurrency : # never run two of these at once
16+ group : pr-slice-internal
17+ cancel-in-progress : true
18+ env :
19+ GH_TOKEN : ${{ secrets.GITHUB_TOKEN }} # gh picks this up automatically
1620 steps :
17- - name : Checkout slice/internal
18- uses : actions/checkout@v4
19- with :
20- ref : ${{ github.ref }} # already on slice/internal
21-
22- - name : Create or update PR to master
23- uses : peter-evans/create-pull-request@v6
24- with :
25- # token: ${{ secrets.GITHUB_TOKEN }}
26-
27- # HEAD (source) and BASE (target) of the PR
28- branch : slice/internal # head branch (already exists)
29- base : master # target branch
30-
31- # Cosmetic bits
32- title : " Sync slice/internal → master"
33- body : |
34- This PR was opened automatically after the internal sync job pushed changes.
35-
36- Triggering commit: ${{ github.sha }}
37- commit-message : " [bot] chore: sync slice/internal → master"
38-
39- # Optional housekeeping — comment these in if you like
40- # draft: true # open as draft first
41- # labels: auto-pr, internal-sync # any default labels to attach
42-
43- # name: Subtree sync PR
44-
45- # on:
46- # push:
47- # branches: [ "slice/internal" ]
48-
49- # jobs:
50- # open-pr:
51- # runs-on: ubuntu-latest
52- # permissions:
53- # contents: write
54- # pull-requests: write
55- # steps:
56- # - uses: actions/checkout@v4
57- # with:
58- # fetch-depth: 0
59- # ref: ${{ github.ref }}
60-
61- # - name: Fetch master branch
62- # run: git fetch origin master:refs/remotes/origin/master
63-
64- # - name: Create PR to master
65- # env:
66- # GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
67- # run: |
68- # gh pr create \
69- # --base master \
70- # --head slice/internal \
71- # --title "Internal Sync" \
72- # --body "This PR was opened automatically after the internal sync job pushed changes." \
73- # --repo ${{ github.repository }} \
74- # --fill \
75- # || echo "PR already exists or no changes to PR"
21+ - uses : actions/checkout@v4
22+ with : {fetch-depth: 0} # full history, just in case
23+
24+ - name : Ensure PR exists
25+ run : |
26+ set -euo pipefail
27+
28+ # Does an open PR from slice/internal -> master already exist?
29+ pr_number=$(gh pr list \
30+ --head slice/internal \
31+ --base master \
32+ --state open \
33+ --json number \
34+ --jq '.[0].number' || true)
35+
36+ if [[ -z "$pr_number" ]]; then
37+ echo "No open PR found – creating one."
38+ gh pr create \
39+ --head slice/internal \
40+ --base master \
41+ --title "Sync slice/internal → master" \
42+ --body "Automated PR – triggered by commit $GITHUB_SHA"
43+ else
44+ echo "PR #$pr_number already exists – nothing to do."
45+ fi
0 commit comments