Skip to content

Commit ea17979

Browse files
authored
harden ci (#232)
1 parent 2c22020 commit ea17979

File tree

4 files changed

+61
-8
lines changed

4 files changed

+61
-8
lines changed

.github/CODEOWNERS

+3
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/.github @mensfeld
2+
/.github/workflows/ @mensfeld
3+
/.github/actions/ @mensfeld

.github/workflows/ci.yml

+32-8
Original file line numberDiff line numberDiff line change
@@ -6,12 +6,18 @@ concurrency:
66

77
on:
88
pull_request:
9+
branches: [ main, master ]
910
push:
11+
branches: [ main, master ]
1012
schedule:
11-
- cron: '0 1 * * *'
13+
- cron: '0 1 * * *'
14+
15+
permissions:
16+
contents: read
1217

1318
jobs:
1419
specs:
20+
timeout-minutes: 30
1521
runs-on: ubuntu-latest
1622
needs: diffend
1723
strategy:
@@ -26,13 +32,15 @@ jobs:
2632
- ruby: '3.3'
2733
coverage: 'true'
2834
steps:
29-
- uses: actions/checkout@v4
35+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
36+
with:
37+
fetch-depth: 0
3038

3139
- name: Install package dependencies
3240
run: "[ -e $APT_DEPS ] || sudo apt-get install -y --no-install-recommends $APT_DEPS"
3341

3442
- name: Set up Ruby
35-
uses: ruby/setup-ruby@v1
43+
uses: ruby/setup-ruby@f0a4d6bddd8e71bd3268c611f7ea6f41dce6d7fd
3644
with:
3745
ruby-version: ${{matrix.ruby}}
3846
bundler: 'latest'
@@ -41,24 +49,24 @@ jobs:
4149
run: |
4250
gem install bundler --no-document
4351
gem update --system --no-document
44-
4552
bundle config set without 'tools benchmarks docs'
4653
4754
- name: Bundle install
4855
run: |
4956
bundle install --jobs 4 --retry 3
5057
5158
diffend:
59+
timeout-minutes: 5
5260
runs-on: ubuntu-latest
5361
strategy:
5462
fail-fast: false
5563
steps:
56-
- uses: actions/checkout@v4
64+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
5765
with:
5866
fetch-depth: 0
5967

6068
- name: Set up Ruby
61-
uses: ruby/setup-ruby@v1
69+
uses: ruby/setup-ruby@f0a4d6bddd8e71bd3268c611f7ea6f41dce6d7fd
6270
with:
6371
ruby-version: 3.3
6472

@@ -72,12 +80,28 @@ jobs:
7280
run: bundle secure
7381

7482
coditsu:
83+
timeout-minutes: 5
7584
runs-on: ubuntu-latest
7685
strategy:
7786
fail-fast: false
7887
steps:
79-
- uses: actions/checkout@v4
88+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
8089
with:
8190
fetch-depth: 0
91+
92+
- name: Download Coditsu script
93+
run: |
94+
curl -sSL https://api.coditsu.io/run/ci -o coditsu_script.sh
95+
chmod +x coditsu_script.sh
96+
97+
- name: Verify Coditsu script checksum
98+
run: |
99+
EXPECTED_SHA256="0aecc5aa010f53fca264548a41467a2b0a1208d750ce1da3e98a217304cacbbc"
100+
ACTUAL_SHA256=$(sha256sum coditsu_script.sh | awk '{ print $1 }')
101+
if [ "$ACTUAL_SHA256" != "$EXPECTED_SHA256" ]; then
102+
echo "::error::Checksum verification failed. Expected $EXPECTED_SHA256 but got $ACTUAL_SHA256."
103+
exit 1
104+
fi
105+
82106
- name: Run Coditsu
83-
run: \curl -sSL https://api.coditsu.io/run/ci | bash
107+
run: ./coditsu_script.sh
+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
name: Verify Action Pins
2+
on:
3+
pull_request:
4+
paths:
5+
- '.github/workflows/**'
6+
jobs:
7+
verify:
8+
runs-on: ubuntu-latest
9+
steps:
10+
- uses: actions/checkout@85e6279cec87321a52edac9c87bce653a07cf6c2
11+
- name: Check SHA pins
12+
run: |
13+
if grep -E -r "uses: .*/.*@(v[0-9]+|main|master)" .github/workflows/; then
14+
echo "::error::Actions should use SHA pins, not tags or branch names"
15+
exit 1
16+
fi

renovate.json

+10
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,15 @@
22
"$schema": "https://docs.renovatebot.com/renovate-schema.json",
33
"extends": [
44
"config:base"
5+
],
6+
"github-actions": {
7+
"enabled": true,
8+
"pinDigests": true
9+
},
10+
"packageRules": [
11+
{
12+
"matchManagers": ["github-actions"],
13+
"minimumReleaseAge": "7 days"
14+
}
515
]
616
}

0 commit comments

Comments
 (0)