forked from hugcabbage/shared-lede
-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (78 loc) · 2.35 KB
/
renew.yml
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
name: renew
on:
workflow_dispatch:
inputs:
deploydir:
description: 'file(s) directory'
required: true
type: string
default: 'preset-lede'
dotconfig:
description: '<serial>.config file(s)'
required: true
type: string
default: '1.config, 2.config'
permissions:
contents: write
jobs:
set-matrix:
runs-on: ubuntu-latest
outputs:
dotconfig: ${{ steps.set-matrix.outputs.dotconfig }}
deploydir: ${{ steps.set-matrix.outputs.deploydir }}
steps:
- uses: actions/checkout@v4
- id: set-matrix
uses: actions/github-script@v6
with:
script: |
const fs = require('fs');
let dotconfig = [];
let cLs = "${{ inputs.dotconfig }}".replaceAll(' ', '').split(',');
let deploydir = "${{ inputs.deploydir }}".trim();
if (deploydir.endsWith('/')) deploydir = deploydir.slice(0, -1);
for (i=0; i<cLs.length; i++) {
try {
fs.accessSync(deploydir + '/' + cLs[i]);
dotconfig.push(cLs[i]);
}
catch (err) {
console.log(cLs[i] + ' does not exist!');
}
}
core.setOutput("dotconfig", JSON.stringify(dotconfig));
core.setOutput("deploydir", deploydir);
renew:
needs: set-matrix
runs-on: ubuntu-latest
env:
DEPLOY_DIR: ${{ needs.set-matrix.outputs.deploydir }}
DOT_CONFIG: ${{ matrix.dotconfig }}
strategy:
matrix:
dotconfig: ${{ fromJSON(needs.set-matrix.outputs.dotconfig) }}
steps:
- uses: actions/checkout@v4
- name: Carry out
env:
RENEW_PY: extra-files/renew.py
run: |
chmod +x $RENEW_PY
$RENEW_PY
- uses: actions/upload-artifact@v4
with:
name: ${{ env.DEPLOY_DIR }}
path: ${{ env.DEPLOY_DIR }}
commit:
needs: renew
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: actions/download-artifact@v3
- uses: geekyeggo/delete-artifact@v2
with:
name: '*'
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: renew .config files
commit_author: github-actions[bot] <github-actions[bot]@users.noreply.github.com>