-
Notifications
You must be signed in to change notification settings - Fork 2
72 lines (65 loc) · 2.32 KB
/
__update_license_years.yml
File metadata and controls
72 lines (65 loc) · 2.32 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
---
# Update the year in license files
name: Update License Years
permissions: {}
on:
schedule:
- cron: '0 2 1 1 *' # run on 1st Jan every year at 2am UTC
workflow_dispatch:
jobs:
setup-matrix:
name: Setup Matrix
runs-on: ubuntu-latest
outputs:
matrix: ${{ steps.set-matrix.outputs.result }}
permissions: {}
steps:
# get all repos in this org
- name: Get repos
id: set-matrix
uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0
with:
script: |
const opts = github.rest.repos.listForOrg.endpoint.merge({ org: context.repo.owner });
const repos = await github.paginate(opts)
// create a GitHub strategy matrix
let matrix = { "include": [] };
for (const repo of repos) {
if (!repo.archived && !repo.fork) {
matrix.include.push({ "repo": repo.name });
}
}
return matrix
update:
name: Update License Year (${{ matrix.repo }})
needs: setup-matrix
permissions: {}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
max-parallel: 5 # run only a few at a time to attempt to avoid GitHub api rate limits
steps:
- name: Checkout
uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
repository: ${{ github.repository_owner }}/${{ matrix.repo }}
fetch-depth: 0
- name: LICENSE exists
id: license-exists
shell: bash
run: |
license_exists=true
if [ ! -f LICENSE ]; then
license_exists=false
fi
echo "license_exists=${license_exists}" >> "${GITHUB_OUTPUT}"
- name: Update license year
if: steps.license-exists.outputs.license_exists == 'true'
uses: FantasticFiasco/action-update-license-year@f180e962fa988db222d8f03ef4636750312d1b3d # v3.0.4
with:
commitAuthorEmail: ${{ secrets.GH_BOT_EMAIL }}
commitAuthorName: ${{ vars.GH_BOT_NAME }}
commitTitle: 'docs(license): update copyright year(s) to {{currentYear}}'
prTitle: 'docs(license): update copyright year(s) to {{currentYear}}'
token: ${{ secrets.GH_BOT_TOKEN }}