Skip to content

Commit e4c82bd

Browse files
committed
Restrict GitHub Actions workflow permissions for newgem
- Configure minimal required permissions in the GitHub Actions workflow template - Bump actions/checkout from 4 to 6 - Bump actions/upload-artifact from 3 to 7
1 parent ae0fcb3 commit e4c82bd

2 files changed

Lines changed: 12 additions & 5 deletions

File tree

bundler/lib/bundler/templates/newgem/github/workflows/build-gems.yml.tt

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,10 @@ on:
88
- "cross-gem/*"
99
workflow_dispatch:
1010

11+
permissions:
12+
contents: read
13+
packages: write
14+
1115
jobs:
1216
ci-data:
1317
runs-on: ubuntu-latest
@@ -25,7 +29,7 @@ jobs:
2529
source-gem:
2630
runs-on: ubuntu-latest
2731
steps:
28-
- uses: actions/checkout@v4
32+
- uses: actions/checkout@v6
2933

3034
- uses: ruby/setup-ruby@v1
3135
with:
@@ -34,7 +38,7 @@ jobs:
3438
- name: Build gem
3539
run: bundle exec rake build
3640

37-
- uses: actions/upload-artifact@v3
41+
- uses: actions/upload-artifact@v7
3842
with:
3943
name: source-gem
4044
path: pkg/*.gem
@@ -47,7 +51,7 @@ jobs:
4751
matrix:
4852
platform: ${{ fromJSON(needs.ci-data.outputs.result).supported-ruby-platforms }}
4953
steps:
50-
- uses: actions/checkout@v4
54+
- uses: actions/checkout@v6
5155

5256
- uses: ruby/setup-ruby@v1
5357
with:
@@ -59,7 +63,7 @@ jobs:
5963
platform: ${{ matrix.platform }}
6064
ruby-versions: ${{ join(fromJSON(needs.ci-data.outputs.result).stable-ruby-versions, ',') }}
6165

62-
- uses: actions/upload-artifact@v3
66+
- uses: actions/upload-artifact@v7
6367
with:
6468
name: cross-gem
6569
path: ${{ steps.cross-gem.outputs.gem-path }}

bundler/lib/bundler/templates/newgem/github/workflows/main.yml.tt

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77

88
pull_request:
99

10+
permissions:
11+
contents: read
12+
1013
jobs:
1114
build:
1215
runs-on: ubuntu-latest
@@ -17,7 +20,7 @@ jobs:
1720
- '<%= RUBY_VERSION %>'
1821

1922
steps:
20-
- uses: actions/checkout@v4
23+
- uses: actions/checkout@v6
2124
with:
2225
persist-credentials: false
2326
<%- if config[:ext] == 'rust' -%>

0 commit comments

Comments
 (0)