Skip to content

Commit e9783b8

Browse files
zkoppertCopilot
andcommitted
docs: add cache restore/save steps to all example workflows
All 4 example workflows (org-wide, single repo, GitHub App, team rollout) now include the recommended cache-based state persistence pattern with restore-keys prefix matching and save conditioned on detect step success. Also removed unnecessary 'contents: read' permission since the cache API doesn't require it. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
1 parent af7b59d commit e9783b8

1 file changed

Lines changed: 60 additions & 4 deletions

File tree

README.md

Lines changed: 60 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,6 @@ on:
125125
workflow_dispatch:
126126

127127
permissions:
128-
contents: read
129128
issues: write
130129
pull-requests: write
131130

@@ -134,13 +133,28 @@ jobs:
134133
name: Detect PR conflicts
135134
runs-on: ubuntu-latest
136135
steps:
136+
- name: Restore conflict state
137+
uses: actions/cache/restore@v4
138+
with:
139+
path: .pr-conflict-state.json
140+
key: pr-conflict-state-${{ github.run_id }}
141+
restore-keys: pr-conflict-state-
142+
137143
- name: Detect PR Conflicts
144+
id: detect
138145
uses: github-community-projects/pr-conflict-detector@v1
139146
env:
140147
GH_TOKEN: ${{ secrets.GH_TOKEN }}
141148
ORGANIZATION: my-org
142149
INCLUDE_DRAFTS: "true"
143150
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
151+
152+
- name: Save conflict state
153+
if: steps.detect.outcome == 'success'
154+
uses: actions/cache/save@v4
155+
with:
156+
path: .pr-conflict-state.json
157+
key: pr-conflict-state-${{ github.run_id }}
144158
```
145159
146160
#### Single repository
@@ -153,7 +167,6 @@ on:
153167
workflow_dispatch:
154168

155169
permissions:
156-
contents: read
157170
issues: write
158171
pull-requests: write
159172

@@ -162,11 +175,26 @@ jobs:
162175
name: Detect PR conflicts
163176
runs-on: ubuntu-latest
164177
steps:
178+
- name: Restore conflict state
179+
uses: actions/cache/restore@v4
180+
with:
181+
path: .pr-conflict-state.json
182+
key: pr-conflict-state-${{ github.run_id }}
183+
restore-keys: pr-conflict-state-
184+
165185
- name: Detect PR Conflicts
186+
id: detect
166187
uses: github-community-projects/pr-conflict-detector@v1
167188
env:
168189
GH_TOKEN: ${{ secrets.GH_TOKEN }}
169190
REPOSITORY: owner/repo-name
191+
192+
- name: Save conflict state
193+
if: steps.detect.outcome == 'success'
194+
uses: actions/cache/save@v4
195+
with:
196+
path: .pr-conflict-state.json
197+
key: pr-conflict-state-${{ github.run_id }}
170198
```
171199
172200
#### Multiple repositories with GitHub App authentication
@@ -179,7 +207,6 @@ on:
179207
workflow_dispatch:
180208

181209
permissions:
182-
contents: read
183210
issues: write
184211
pull-requests: write
185212

@@ -188,7 +215,15 @@ jobs:
188215
name: Detect PR conflicts
189216
runs-on: ubuntu-latest
190217
steps:
218+
- name: Restore conflict state
219+
uses: actions/cache/restore@v4
220+
with:
221+
path: .pr-conflict-state.json
222+
key: pr-conflict-state-${{ github.run_id }}
223+
restore-keys: pr-conflict-state-
224+
191225
- name: Detect PR Conflicts
226+
id: detect
192227
uses: github-community-projects/pr-conflict-detector@v1
193228
env:
194229
GH_APP_ID: ${{ secrets.GH_APP_ID }}
@@ -197,6 +232,13 @@ jobs:
197232
REPOSITORY: "owner/repo1,owner/repo2,owner/repo3"
198233
EXEMPT_REPOS: "owner/repo-to-skip"
199234
VERIFY_CONFLICTS: "true"
235+
236+
- name: Save conflict state
237+
if: steps.detect.outcome == 'success'
238+
uses: actions/cache/save@v4
239+
with:
240+
path: .pr-conflict-state.json
241+
key: pr-conflict-state-${{ github.run_id }}
200242
```
201243
202244
#### Incremental rollout to a specific team
@@ -211,7 +253,6 @@ on:
211253
workflow_dispatch:
212254
213255
permissions:
214-
contents: read
215256
issues: write
216257
pull-requests: write
217258
@@ -220,13 +261,28 @@ jobs:
220261
name: Detect PR conflicts
221262
runs-on: ubuntu-latest
222263
steps:
264+
- name: Restore conflict state
265+
uses: actions/cache/restore@v4
266+
with:
267+
path: .pr-conflict-state.json
268+
key: pr-conflict-state-${{ github.run_id }}
269+
restore-keys: pr-conflict-state-
270+
223271
- name: Detect PR Conflicts
272+
id: detect
224273
uses: github-community-projects/pr-conflict-detector@v1
225274
env:
226275
GH_TOKEN: ${{ secrets.GH_TOKEN }}
227276
REPOSITORY: my-org/company-monolith
228277
FILTER_TEAMS: "my-org/frontend-team,my-org/backend-team"
229278
DRY_RUN: "true"
279+
280+
- name: Save conflict state
281+
if: steps.detect.outcome == 'success'
282+
uses: actions/cache/save@v4
283+
with:
284+
path: .pr-conflict-state.json
285+
key: pr-conflict-state-${{ github.run_id }}
230286
```
231287

232288
You can also combine `FILTER_TEAMS` with `FILTER_AUTHORS` — the members are merged (union):

0 commit comments

Comments
 (0)