Skip to content

Commit 22e6273

Browse files
feat(workflows): add license update workflow (#519)
1 parent 5e075e8 commit 22e6273

1 file changed

Lines changed: 58 additions & 0 deletions

File tree

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
---
2+
# Update the year in license files
3+
4+
name: Update License Years
5+
permissions: {}
6+
7+
on:
8+
schedule:
9+
- cron: '0 2 1 1 *' # run on 1st Jan every year at 2am UTC
10+
workflow_dispatch:
11+
12+
jobs:
13+
setup-matrix:
14+
name: Setup Matrix
15+
runs-on: ubuntu-latest
16+
outputs:
17+
matrix: ${{ steps.set-matrix.outputs.result }}
18+
steps:
19+
# get all repos in this org
20+
- name: Get repos
21+
id: set-matrix
22+
uses: actions/github-script@v8
23+
with:
24+
script: |
25+
const opts = github.rest.repos.listForOrg.endpoint.merge({ org: context.repo.owner });
26+
const repos = await github.paginate(opts)
27+
28+
// create a GitHub strategy matrix
29+
let matrix = { "include": [] };
30+
for (const repo of repos) {
31+
matrix.include.push({ "repo": repo.name });
32+
}
33+
return matrix
34+
35+
update:
36+
name: Update License Year (${{ matrix.repo }})
37+
needs: setup-matrix
38+
runs-on: ubuntu-latest
39+
strategy:
40+
fail-fast: false
41+
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix) }}
42+
max-parallel: 1 # run one at a time to attempt to avoid GitHub api rate limits
43+
steps:
44+
- name: Checkout
45+
uses: actions/checkout@v5
46+
with:
47+
repository: ${{ github.repository_owner }}/${{ matrix.repo }}
48+
fetch-depth: 0
49+
persist-credentials: false
50+
51+
- name: Update license year
52+
uses: FantasticFiasco/action-update-license-year@v3
53+
with:
54+
commitAuthorEmail: ${{ secrets.GH_BOT_EMAIL }}
55+
commitAuthorName: ${{ secrets.GH_BOT_NAME }}
56+
commitTitle: 'docs(license): update copyright year(s) to {{currentYear}}'
57+
prTitle: 'docs(license): update copyright year(s) to {{currentYear}}'
58+
token: ${{ secrets.GH_BOT_TOKEN }}

0 commit comments

Comments
 (0)