Skip to content

Commit 049c271

Browse files
committed
Pull some of the GitHub actions updates from main
1 parent 8d305b4 commit 049c271

File tree

5 files changed

+102
-16
lines changed

5 files changed

+102
-16
lines changed

.github/workflows/ci.yml

Lines changed: 63 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,16 @@ on:
44
secrets:
55
codecov_token:
66
required: true
7+
permissions: {}
78
jobs:
89
lint:
910
name: Lint source files
1011
runs-on: ubuntu-latest
12+
permissions:
13+
contents: read # for actions/checkout
1114
steps:
1215
- name: Checkout repo
13-
uses: actions/checkout@v2
16+
uses: actions/checkout@v4
1417
with:
1518
persist-credentials: false
1619

@@ -35,31 +38,44 @@ jobs:
3538
- name: Spellcheck
3639
run: npm run check:spelling
3740

41+
- name: Lint GitHub Actions
42+
uses: docker://rhysd/actionlint:latest
43+
with:
44+
args: -color
45+
3846
checkForCommonlyIgnoredFiles:
3947
name: Check for commonly ignored files
4048
runs-on: ubuntu-latest
49+
permissions:
50+
contents: read # for actions/checkout
4151
steps:
4252
- name: Checkout repo
43-
uses: actions/checkout@v2
53+
uses: actions/checkout@v4
4454
with:
4555
persist-credentials: false
4656

4757
- name: Check if commit contains files that should be ignored
4858
run: |
49-
git clone --depth 1 https://github.com/github/gitignore.git &&
50-
cat gitignore/Node.gitignore $(find gitignore/Global -name "*.gitignore" | grep -v ModelSim) > all.gitignore &&
51-
if [[ "$(git ls-files -iX all.gitignore)" != "" ]]; then
52-
echo "::error::Please remove these files:"
53-
git ls-files -iX all.gitignore
59+
git clone --depth 1 https://github.com/github/gitignore.git
60+
61+
rm gitignore/Global/ModelSim.gitignore
62+
rm gitignore/Global/Images.gitignore
63+
cat gitignore/Node.gitignore gitignore/Global/*.gitignore > all.gitignore
64+
65+
IGNORED_FILES=$(git ls-files --cached --ignored --exclude-from=all.gitignore)
66+
if [[ "$IGNORED_FILES" != "" ]]; then
67+
echo -e "::error::Please remove these files:\n$IGNORED_FILES" | sed -z 's/\n/%0A/g'
5468
exit 1
5569
fi
5670
5771
checkPackageLock:
5872
name: Check health of package-lock.json file
5973
runs-on: ubuntu-latest
74+
permissions:
75+
contents: read # for actions/checkout
6076
steps:
6177
- name: Checkout repo
62-
uses: actions/checkout@v2
78+
uses: actions/checkout@v4
6379
with:
6480
persist-credentials: false
6581

@@ -72,6 +88,9 @@ jobs:
7288
- name: Install Dependencies
7389
run: npm ci --ignore-scripts
7490

91+
- name: Check that package-lock.json doesn't have conflicts
92+
run: npm ls --depth 999
93+
7594
- name: Run npm install
7695
run: npm install --ignore-scripts --force --package-lock-only --engine-strict --strict-peer-deps
7796

@@ -81,9 +100,11 @@ jobs:
81100
integrationTests:
82101
name: Run integration tests
83102
runs-on: ubuntu-latest
103+
permissions:
104+
contents: read # for actions/checkout
84105
steps:
85106
- name: Checkout repo
86-
uses: actions/checkout@v2
107+
uses: actions/checkout@v4
87108
with:
88109
persist-credentials: false
89110

@@ -103,9 +124,11 @@ jobs:
103124
fuzz:
104125
name: Run fuzzing tests
105126
runs-on: ubuntu-latest
127+
permissions:
128+
contents: read # for actions/checkout
106129
steps:
107130
- name: Checkout repo
108-
uses: actions/checkout@v2
131+
uses: actions/checkout@v4
109132
with:
110133
persist-credentials: false
111134

@@ -156,9 +179,11 @@ jobs:
156179
strategy:
157180
matrix:
158181
node_version_to_setup: [12, 14, 16, 17]
182+
permissions:
183+
contents: read # for actions/checkout
159184
steps:
160185
- name: Checkout repo
161-
uses: actions/checkout@v2
186+
uses: actions/checkout@v4
162187
with:
163188
persist-credentials: false
164189

@@ -174,13 +199,35 @@ jobs:
174199
- name: Run Tests
175200
run: npm run testonly
176201

202+
codeql:
203+
name: Run CodeQL security scan
204+
runs-on: ubuntu-latest
205+
permissions:
206+
contents: read # for actions/checkout
207+
security-events: write # for codeql-action
208+
steps:
209+
- name: Checkout repo
210+
uses: actions/checkout@v4
211+
with:
212+
persist-credentials: false
213+
214+
- name: Initialize CodeQL
215+
uses: github/codeql-action/init@v3
216+
with:
217+
languages: 'javascript, typescript'
218+
219+
- name: Perform CodeQL analysis
220+
uses: github/codeql-action/analyze@v3
221+
177222
build-npm-dist:
178223
name: Build 'npmDist' artifact
179224
runs-on: ubuntu-latest
180225
needs: [test, fuzz, lint, integrationTests]
226+
permissions:
227+
contents: read # for actions/checkout
181228
steps:
182229
- name: Checkout repo
183-
uses: actions/checkout@v2
230+
uses: actions/checkout@v4
184231
with:
185232
persist-credentials: false
186233

@@ -206,15 +253,18 @@ jobs:
206253
name: Build 'denoDist' artifact
207254
runs-on: ubuntu-latest
208255
needs: [test, fuzz, lint, integrationTests]
256+
permissions:
257+
contents: read # for actions/checkout
209258
steps:
210259
- name: Checkout repo
211-
uses: actions/checkout@v2
260+
uses: actions/checkout@v4
212261
with:
213262
persist-credentials: false
214263

215264
- name: Setup Node.js
216265
uses: actions/setup-node@v4
217266
with:
267+
cache: npm
218268
node-version-file: '.node-version'
219269

220270
- name: Install Dependencies

.github/workflows/deploy-artifact-as-branch.yml

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,26 +3,33 @@ on:
33
workflow_call:
44
inputs:
55
environment:
6+
description: Environment to publish under
67
required: true
78
type: string
89
artifact_name:
10+
description: Artifact name
911
required: true
1012
type: string
1113
target_branch:
14+
description: Target branch
1215
required: true
1316
type: string
1417
commit_message:
18+
description: Commit message
1519
required: true
1620
type: string
21+
permissions: {}
1722
jobs:
1823
deploy-artifact-as-branch:
1924
environment:
2025
name: ${{ inputs.environment }}
2126
url: ${{ github.server_url }}/${{ github.repository }}/tree/${{ inputs.target_branch }}
2227
runs-on: ubuntu-latest
28+
permissions:
29+
contents: write # for actions/checkout and to push branch
2330
steps:
2431
- name: Checkout `${{ inputs.target_branch }}` branch
25-
uses: actions/checkout@v2
32+
uses: actions/checkout@v4
2633
with:
2734
ref: ${{ inputs.target_branch }}
2835

.github/workflows/pull_request.yml

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,44 @@
11
name: PullRequest
22
on: pull_request
3+
permissions: {}
34
jobs:
45
ci:
6+
permissions:
7+
contents: read # for actions/checkout
8+
security-events: write # for codeql-action
59
uses: ./.github/workflows/ci.yml
610
secrets:
711
codecov_token: ${{ secrets.CODECOV_TOKEN }}
812

13+
dependency-review:
14+
name: Security check of added dependencies
15+
runs-on: ubuntu-latest
16+
permissions:
17+
contents: read # for actions/checkout
18+
steps:
19+
- name: Checkout repo
20+
uses: actions/checkout@v4
21+
with:
22+
persist-credentials: false
23+
24+
- name: Dependency review
25+
uses: actions/dependency-review-action@v2
26+
927
diff-npm-package:
1028
name: Diff content of NPM package
1129
runs-on: ubuntu-latest
30+
permissions:
31+
contents: read # for actions/checkout
1232
steps:
1333
- name: Checkout repo
14-
uses: actions/checkout@v2
34+
uses: actions/checkout@v4
1535
with:
1636
persist-credentials: false
1737

1838
- name: Deepen cloned repo
1939
env:
2040
BASE_SHA: ${{ github.event.pull_request.base.sha }}
21-
run: 'git fetch --depth=1 origin $BASE_SHA:refs/tags/BASE'
41+
run: 'git fetch --depth=1 origin "$BASE_SHA:refs/tags/BASE"'
2242

2343
- name: Setup Node.js
2444
uses: actions/setup-node@v4

.github/workflows/pull_request_opened.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@ name: PullRequestOpened
22
on:
33
pull_request:
44
types: [opened]
5+
permissions: {}
56
jobs:
67
save-github-event:
78
name: "Save `github.event` as an artifact to use in subsequent 'workflow_run' actions"

.github/workflows/push.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,20 @@
11
name: Push
22
on: push
3+
permissions: {}
34
jobs:
45
ci:
6+
permissions:
7+
contents: read # for actions/checkout
8+
security-events: write
59
uses: ./.github/workflows/ci.yml
610
secrets:
711
codecov_token: ${{ secrets.CODECOV_TOKEN }}
812
deploy-to-npm-branch:
913
name: Deploy to `npm` branch
1014
needs: ci
1115
if: github.ref == 'refs/heads/main'
16+
permissions:
17+
contents: write # for actions/checkout and to push branch
1218
uses: ./.github/workflows/deploy-artifact-as-branch.yml
1319
with:
1420
environment: npm-branch
@@ -20,6 +26,8 @@ jobs:
2026
name: Deploy to `deno` branch
2127
needs: ci
2228
if: github.ref == 'refs/heads/main'
29+
permissions:
30+
contents: write # for actions/checkout and to push branch
2331
uses: ./.github/workflows/deploy-artifact-as-branch.yml
2432
with:
2533
environment: deno-branch

0 commit comments

Comments
 (0)