55 schedule :
66 - cron : " 17 */6 * * *"
77 workflow_dispatch :
8+ inputs :
9+ source_commit :
10+ description : Exact Intelligence Flow commit to project (defaults to main)
11+ required : false
12+ type : string
813
914permissions :
1015 contents : write
@@ -18,29 +23,53 @@ jobs:
1823 sync :
1924 runs-on : ubuntu-latest
2025 steps :
26+ - name : Create repository automation token
27+ id : app-token
28+ uses : actions/create-github-app-token@v3
29+ with :
30+ client-id : ${{ vars.BOATSTACK_APP_CLIENT_ID }}
31+ private-key : ${{ secrets.BOATSTACK_APP_PRIVATE_KEY }}
32+ owner : operatorstack
33+ repositories : |
34+ intelligence-flow
35+ boatstack
36+ permission-contents : write
37+ permission-pull-requests : write
2138 - name : Check out Boatstack
2239 uses : actions/checkout@v4
2340 with :
2441 path : boatstack-repo
42+ token : ${{ steps.app-token.outputs.token }}
2543 - name : Check out Intelligence Flow
2644 uses : actions/checkout@v4
2745 with :
2846 repository : operatorstack/intelligence-flow
29- ref : main
47+ ref : ${{ inputs.source_commit || 'main' }}
48+ fetch-depth : 0
3049 path : intelligence-flow
50+ token : ${{ steps.app-token.outputs.token }}
3151 - name : Generate projection
3252 id : generate
3353 shell : bash
3454 run : |
3555 source_commit="$(git -C intelligence-flow log -1 --format=%H -- examples/12-product-engineering-loop)"
56+ current_commit="$(jq -r '.source.commit // empty' boatstack-repo/UPSTREAM.json)"
57+ if [[ -n "$current_commit" ]] &&
58+ ! git -C intelligence-flow merge-base --is-ancestor "$current_commit" "$source_commit"; then
59+ echo "Ignoring stale projection request $source_commit; Boatstack already records $current_commit."
60+ echo "stale=true" >> "$GITHUB_OUTPUT"
61+ exit 0
62+ fi
3663 python3 intelligence-flow/examples/12-product-engineering-loop/scripts/build_boatstack.py \
3764 --repo boatstack-repo \
3865 --source-commit "$source_commit" \
3966 --write
4067 echo "source_commit=$source_commit" >> "$GITHUB_OUTPUT"
68+ echo "stale=false" >> "$GITHUB_OUTPUT"
4169 - name : Open generated pull request
70+ if : steps.generate.outputs.stale != 'true'
4271 env :
43- GH_TOKEN : ${{ github .token }}
72+ GH_TOKEN : ${{ steps.app-token.outputs .token }}
4473 SOURCE_COMMIT : ${{ steps.generate.outputs.source_commit }}
4574 shell : bash
4675 run : |
@@ -92,13 +121,14 @@ jobs:
92121 echo "Upstream PR already open: $existing"
93122 exit 0
94123 fi
95- git config user.name "github-actions [bot]"
96- git config user.email "41898282+github-actions [bot]@users.noreply.github.com"
124+ git config user.name "${{ steps.app-token.outputs.app-slug }} [bot]"
125+ git config user.email "${{ steps.app-token.outputs.app-slug }} [bot]@users.noreply.github.com"
97126 git switch -c "$branch"
98127 git commit -m "Sync Boatstack from Intelligence Flow $short"
99128 git push --set-upstream origin "$branch"
100- gh pr create \
129+ pr_url="$( gh pr create \
101130 --base main \
102131 --head "$branch" \
103132 --title "Sync Boatstack from Intelligence Flow $short" \
104- --body-file "$body_file"
133+ --body-file "$body_file")"
134+ echo "Opened generated PR: $pr_url"
0 commit comments