Repository navigation
96 lines (91 loc) · 3.88 KB
/
Copy pathruntime-maintenance.yml
File metadata and controls
96 lines (91 loc) · 3.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
name: Bundled Runtime Maintenance
on:
schedule:
- cron: '23 7 * * *'
workflow_dispatch:
permissions:
contents: read
concurrency:
group: bundled-runtime-maintenance
cancel-in-progress: false
jobs:
check:
# Never run maintenance code from a manually selected branch.
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch)
runs-on: ubuntu-latest
timeout-minutes: 15
outputs:
pin: ${{ steps.runtime.outputs.pin }}
target: ${{ steps.runtime.outputs.target }}
node-update: ${{ steps.runtime.outputs.node-update }}
npm-pin: ${{ steps.runtime.outputs.npm-pin }}
npm-target: ${{ steps.runtime.outputs.npm-target }}
npm-update: ${{ steps.runtime.outputs.npm-update }}
npm-engine: ${{ steps.runtime.outputs.npm-engine }}
electron: ${{ steps.runtime.outputs.electron }}
electron-node: ${{ steps.runtime.outputs.electron-node }}
npm-audit: ${{ steps.runtime.outputs.npm-audit }}
npm-pinned-audit: ${{ steps.runtime.outputs.npm-pinned-audit }}
steps:
- uses: actions/checkout@v7.0.1
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- uses: actions/setup-node@v7.1.0
with:
node-version-file: .node-version
package-manager-cache: false
- name: Test maintenance policy
run: node --test .github/scripts/runtime-maintenance.test.cjs
- name: Check Node LTS and npm, and audit the bundled and latest npm
id: runtime
run: npm run check:runtime
- name: Retain the npm advisory report for manual assessment
uses: actions/upload-artifact@v7.0.2
with:
name: bundled-npm-audit
path: ${{ runner.temp }}/bundled-npm-audit.json
retention-days: 7
if-no-files-found: error
propose:
needs: check
if: github.ref == format('refs/heads/{0}', github.event.repository.default_branch) && (needs.check.outputs.node-update == 'true' || needs.check.outputs.npm-update == 'true')
runs-on: ubuntu-latest
timeout-minutes: 5
permissions:
contents: write
pull-requests: write
steps:
- uses: actions/checkout@v7.0.1
with:
ref: ${{ github.event.repository.default_branch }}
persist-credentials: false
- name: Propose a reviewed Node LTS update
if: needs.check.outputs.node-update == 'true'
uses: actions/github-script@v9.0.0
env:
NODE_PIN: ${{ needs.check.outputs.pin }}
NODE_TARGET: ${{ needs.check.outputs.target }}
with:
script: |
const { proposeNodeUpdate } = require('./.github/scripts/runtime-maintenance.cjs');
await proposeNodeUpdate({ github, context, core, pin: process.env.NODE_PIN, target: process.env.NODE_TARGET });
- name: Propose a reviewed npm update
if: needs.check.outputs.npm-update == 'true'
uses: actions/github-script@v9.0.0
env:
NODE_PIN: ${{ needs.check.outputs.pin }}
NPM_PIN: ${{ needs.check.outputs.npm-pin }}
NPM_TARGET: ${{ needs.check.outputs.npm-target }}
NPM_ENGINE: ${{ needs.check.outputs.npm-engine }}
ELECTRON: ${{ needs.check.outputs.electron }}
ELECTRON_NODE: ${{ needs.check.outputs.electron-node }}
NPM_AUDIT: ${{ needs.check.outputs.npm-audit }}
NPM_PINNED_AUDIT: ${{ needs.check.outputs.npm-pinned-audit }}
with:
script: |
const { proposeNpmUpdate } = require('./.github/scripts/runtime-maintenance.cjs');
const env = process.env;
await proposeNpmUpdate({ github, context, core, pin: env.NPM_PIN, target: env.NPM_TARGET, engine: env.NPM_ENGINE,
nodePin: env.NODE_PIN, electron: env.ELECTRON, electronNode: env.ELECTRON_NODE,
audit: env.NPM_AUDIT, pinnedAudit: env.NPM_PINNED_AUDIT });