1515 - " --dry-run"
1616 - " --apply"
1717
18+ concurrency :
19+ group : settings-sync
20+ cancel-in-progress : false
21+
1822permissions :
1923 contents : read
20- issues : write
2124
2225jobs :
2326 sync :
2427 name : Sync Settings
2528 runs-on : ubuntu-latest
2629 steps :
2730 - name : Checkout
28- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2 .2
31+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0 .2
2932
3033 - name : Run settings sync
3134 id : sync
3538 github_token : ${{ secrets.ORG_SETTINGS_PAT }}
3639
3740 - name : Upload report artifact
38- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
41+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
3942 with :
4043 name : sync-report-${{ github.run_number }}
4144 path : reports/sync-report.md
@@ -49,42 +52,50 @@ jobs:
4952 echo ""
5053 echo "| Metric | Value |"
5154 echo "| --- | --- |"
52- echo "| Repositories scanned | ${{ steps.sync.outputs.total_repos }} |"
53- echo "| Compliant | ${{ steps.sync.outputs.compliant }} |"
54- echo "| Drift detected | ${{ steps.sync.outputs.drift }} |"
55- echo "| Mode | ${{ github.event.inputs.mode || '--apply' }} |"
55+ echo "| Repositories scanned | $TOTAL_REPOS |"
56+ echo "| Compliant | $COMPLIANT |"
57+ echo "| Drift detected | $DRIFT |"
58+ echo "| Mode | $MODE |"
5659 echo ""
5760 echo "### Full Report"
5861 echo ""
5962 cat reports/sync-report.md
6063 } >> "$GITHUB_STEP_SUMMARY"
64+ env :
65+ TOTAL_REPOS : ${{ steps.sync.outputs.total_repos }}
66+ COMPLIANT : ${{ steps.sync.outputs.compliant }}
67+ DRIFT : ${{ steps.sync.outputs.drift }}
68+ MODE : ${{ github.event.inputs.mode || '--apply' }}
6169
62- - name : Create or update drift issue
70+ - name : Create drift issue
6371 if : steps.sync.outputs.has_drift == 'true'
6472 env :
6573 GH_TOKEN : ${{ secrets.ORG_SETTINGS_PAT }}
74+ DRIFT : ${{ steps.sync.outputs.drift }}
75+ TOTAL_REPOS : ${{ steps.sync.outputs.total_repos }}
76+ RUN_URL : ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
77+ SYNC_MODE : ${{ github.event.inputs.mode || '--apply' }}
6678 run : |
6779 TITLE="chore: settings drift detected — $(date '+%Y-%m-%d')"
68- BODY=$(cat <<'ISSUE_EOF'
69- ## Settings Drift Report
80+ BODY="## Settings Drift Report
7081
71- **Run**: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
72- **Mode**: ${{ github.event.inputs.mode || '--apply' }}
73- **Repos with drift**: ${{ steps.sync.outputs.drift }} / ${{ steps.sync.outputs.total_repos }}
82+ **Run**: $RUN_URL
83+ **Mode**: $SYNC_MODE
84+ **Repos with drift**: $DRIFT / $TOTAL_REPOS
7485
75- See the [workflow run](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }} ) for the full report.
86+ See the [workflow run]($RUN_URL ) for the full report."
7687
77- ISSUE_EOF
78- )
88+ # Create new issue first, then close old ones
89+ gh issue create --title "$TITLE" --body "$BODY" --label "settings-drift"
7990
80- # Close previous drift issues
91+ # Close previous drift issues (all except the one just created)
92+ LATEST=$(gh issue list --label "settings-drift" --state open --json number --jq '.[0].number')
8193 gh issue list --label "settings-drift" --state open --json number --jq '.[].number' | while read -r num; do
82- gh issue close "$num" --comment "Superseded by new sync run."
94+ if [ "$num" != "$LATEST" ]; then
95+ gh issue close "$num" --comment "Superseded by new sync run."
96+ fi
8397 done
8498
85- # Create new issue
86- gh issue create --title "$TITLE" --body "$BODY" --label "settings-drift"
87-
8899 - name : Close drift issue if compliant
89100 if : steps.sync.outputs.has_drift == 'false'
90101 env :
99110 runs-on : ubuntu-latest
100111 steps :
101112 - name : Checkout
102- uses : actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2 .2
113+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0 .2
103114
104115 - name : Check for new repos
105116 id : newrepos
@@ -116,7 +127,7 @@ jobs:
116127 || date -u -v-7d '+%Y-%m-%dT%H:%M:%SZ')
117128 NEW_REPOS=$(gh repo list gamaware --no-archived --json name,createdAt \
118129 --jq "[.[] | select(.createdAt > \"$WEEK_AGO\")] | .[].name" \
119- --limit 200 || echo "")
130+ --limit 1000 || echo "")
120131
121132 if [ -n "$NEW_REPOS" ]; then
122133 echo "has_new=true" >> "$GITHUB_OUTPUT"
@@ -148,7 +159,7 @@ jobs:
148159 --label "new-repo"
149160
150161 - name : Upload new repos report
151- uses : actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
162+ uses : actions/upload-artifact@bbbca2ddaa5d8feaa63e36b76fdaad77386f024f # v7.0.0
152163 with :
153164 name : new-repos-report-${{ github.run_number }}
154165 path : reports/new-repos.md
0 commit comments