Skip to content

Commit e93ba0c

Browse files
authored
Merge pull request #73 from posit-dev/ci/fork-safe-pr
Add fork-safe PR workflow and permissions
2 parents efcece8 + a51825b commit e93ba0c

7 files changed

Lines changed: 101 additions & 23 deletions

File tree

.github/workflows/development.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,12 @@ on:
1515
# Hourly rebuild of dev images
1616
- cron: "45 4 * * *" # At 04:45 every day
1717

18-
pull_request:
19-
2018
push:
2119
branches:
2220
- main
2321

22+
2423
concurrency:
25-
# Only cancel in-progress runs for pull_request events, this prevents cancelling workflows against main or tags
26-
# A pull_request will reuse the same group thus enabling cancelation, all others receive a unique run_id
2724
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
2825
cancel-in-progress: true
2926

@@ -37,12 +34,13 @@ jobs:
3734
if: always()
3835

3936
runs-on: ubuntu-latest
37+
permissions: {}
4038
timeout-minutes: 10
4139
needs:
4240
- dev
4341

4442
steps:
45-
- uses: re-actors/alls-green@release/v1
43+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
4644
id: alls-green
4745
with:
4846
jobs: ${{ toJSON(needs) }}

.github/workflows/issues.yml

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -4,29 +4,32 @@ on:
44
types:
55
- opened
66

7+
permissions: {}
8+
79
jobs:
810
issue:
911
# only run in posit-dev/images-workbench.
1012
if: github.repository == 'posit-dev/images-workbench'
1113
runs-on: ubuntu-latest
14+
permissions: {}
1215
steps:
1316

1417
- name: GitHub App Token
15-
uses: actions/create-github-app-token@v3
18+
uses: actions/create-github-app-token@f8d387b68d61c58ab83c6c016672934102569859 # v3.0.0
1619
id: app-token
1720
with:
1821
app-id: ${{ secrets.WORKBENCH_IDE_RELEASE_APP_ID }}
1922
private-key: ${{ secrets.WORKBENCH_IDE_RELEASE_PEM }}
2023

2124
- name: Add to Platform Carbon Project
22-
uses: actions/add-to-project@v1.0.2
25+
uses: actions/add-to-project@244f685bbc3b7adfa8466e08b698b5577571133e # v1.0.2
2326
with:
2427
github-token: ${{ steps.app-token.outputs.token }}
2528
project-url: https://github.com/orgs/posit-dev/projects/17
2629

2730
- name: Add Default Labels
28-
uses: actions-ecosystem/action-add-labels@v1
29-
with:
30-
github_token: ${{ steps.app-token.outputs.token }}
31-
labels: |
32-
docker
31+
env:
32+
GH_TOKEN: ${{ steps.app-token.outputs.token }}
33+
GH_REPO: ${{ github.repository }}
34+
ISSUE_NUMBER: ${{ github.event.issue.number }}
35+
run: gh issue edit "$ISSUE_NUMBER" --add-label "docker"

.github/workflows/pr.yml

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
1+
name: Pull Request
2+
on:
3+
pull_request:
4+
5+
6+
concurrency:
7+
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
8+
cancel-in-progress: true
9+
10+
jobs:
11+
ci:
12+
name: CI
13+
if: always()
14+
runs-on: ubuntu-latest
15+
permissions: {}
16+
timeout-minutes: 10
17+
needs:
18+
- production
19+
- development
20+
- session
21+
- zizmor
22+
steps:
23+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
24+
with:
25+
jobs: ${{ toJSON(needs) }}
26+
27+
production:
28+
name: Production
29+
permissions:
30+
contents: read
31+
packages: write
32+
uses: posit-dev/images-shared/.github/workflows/bakery-build-pr.yml@main
33+
with:
34+
dev-versions: "exclude"
35+
matrix-versions: "exclude"
36+
37+
development:
38+
name: Development
39+
permissions:
40+
contents: read
41+
packages: write
42+
uses: posit-dev/images-shared/.github/workflows/bakery-build-pr.yml@main
43+
with:
44+
dev-versions: "only"
45+
matrix-versions: "exclude"
46+
47+
session:
48+
name: Session
49+
permissions:
50+
contents: read
51+
packages: write
52+
uses: posit-dev/images-shared/.github/workflows/bakery-build-pr.yml@main
53+
with:
54+
matrix-versions: "only"
55+
56+
zizmor:
57+
name: Zizmor
58+
runs-on: ubuntu-latest
59+
permissions:
60+
contents: read
61+
security-events: write
62+
steps:
63+
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
64+
with:
65+
persist-credentials: false
66+
- uses: zizmorcore/zizmor-action@71321a20a9ded102f6e9ce5718a2fcec2c4f70d8 # v0.5.2

.github/workflows/production.yml

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ on:
66
# Weekly rebuild of all images, to pick up any upstream changes.
77
- cron: "15 3 * * 0" # At 03:15 on Sunday
88

9-
pull_request:
10-
119
push:
1210
branches:
1311
- main
1412

13+
1514
concurrency:
16-
# Only cancel in-progress runs for pull_request events, this prevents cancelling workflows against main or tags
17-
# A pull_request will reuse the same group thus enabling cancelation, all others receive a unique run_id
1815
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
1916
cancel-in-progress: true
2017

@@ -28,13 +25,14 @@ jobs:
2825
if: always()
2926

3027
runs-on: ubuntu-latest
28+
permissions: {}
3129
timeout-minutes: 10
3230
needs:
3331
- lint
3432
- build
3533

3634
steps:
37-
- uses: re-actors/alls-green@release/v1
35+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
3836
id: alls-green
3937
with:
4038
jobs: ${{ toJSON(needs) }}

.github/workflows/release.yml

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,14 @@ on:
77
required: true
88
type: string
99

10+
1011
jobs:
1112
release:
13+
if: github.event_name == 'workflow_dispatch'
14+
timeout-minutes: 10
15+
permissions:
16+
contents: write
17+
pull-requests: write
1218
uses: posit-dev/images-shared/.github/workflows/product-release.yml@main
1319
with:
1420
version: ${{ inputs.version }}

.github/workflows/session.yml

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,12 @@ on:
66
# Weekly rebuild of all images, to pick up any upstream changes.
77
- cron: "15 4 * * 0" # At 04:15 on Sunday
88

9-
pull_request:
10-
119
push:
1210
branches:
1311
- main
1412

13+
1514
concurrency:
16-
# Only cancel in-progress runs for pull_request events, this prevents cancelling workflows against main or tags
17-
# A pull_request will reuse the same group thus enabling cancelation, all others receive a unique run_id
1815
group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.run_id }}
1916
cancel-in-progress: true
2017

@@ -23,11 +20,12 @@ jobs:
2320
name: CI
2421
if: always()
2522
runs-on: ubuntu-latest
23+
permissions: {}
2624
timeout-minutes: 10
2725
needs:
2826
- build
2927
steps:
30-
- uses: re-actors/alls-green@release/v1
28+
- uses: re-actors/alls-green@05ac9388f0aebcb5727afa17fcccfecd6f8ec5fe # v1.2.2
3129
id: alls-green
3230
with:
3331
jobs: ${{ toJSON(needs) }}
@@ -46,7 +44,7 @@ jobs:
4644
# Builds all versions of each image in parallel.
4745
#
4846
# Run on merges to main, or on weekly scheduled re-builds.
49-
if: contains(fromJSON('["push", "pull_request"]'), github.event_name) || github.event.schedule == '15 3 * * 0'
47+
if: github.event_name == 'push' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'
5048
permissions:
5149
contents: read
5250
packages: write

.github/zizmor.yml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
rules:
2+
unpinned-uses:
3+
config:
4+
policies:
5+
# Shared workflows and composite actions from images-shared
6+
# are kept at @main intentionally.
7+
"posit-dev/images-shared/*": ref-pin
8+
"*": hash-pin
9+

0 commit comments

Comments
 (0)