-
Notifications
You must be signed in to change notification settings - Fork 3
61 lines (61 loc) · 2.1 KB
/
update-license.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
name: Update License
on:
push:
branches: main
paths: .github/workflows/update-license.yml
schedule:
- cron: '0 0 1 1 *'
workflow_dispatch:
permissions:
contents: read
concurrency: update-license
jobs:
update-license:
name: Update License
runs-on: ubuntu-latest
timeout-minutes: 5
env:
REGEX: ^(((\/\/|#) )?Copyright \(c\) )[0-9]{4}( Devon Powell)$
steps:
- name: Checkout
uses: actions/checkout@v4.1.4
- name: Determine info
shell: bash
id: info
run: |
OLD_YEAR=$(grep -oEi "$REGEX" LICENSE | grep -oEi '[0-9]{4}')
NEW_YEAR=$(date +%Y)
UPDATE_TITLE="Bump license year from $OLD_YEAR to $NEW_YEAR"
UPDATE_BODY="$UPDATE_TITLE."
echo "::set-output name=license-year::$NEW_YEAR"
echo "::set-output name=update-title::$UPDATE_TITLE"
echo "::set-output name=update-body::$UPDATE_BODY"
- name: Update licenses
run: >
find . -type f -not -path './.git/*' -and
-iregex '^.*\(\.\(h\|c\|c\.in\)\|LICENSE\)$'
-exec sed -i -E "s/$REGEX/\1$YEAR\4/" {} \;
env:
YEAR: ${{steps.info.outputs.license-year}}
- name: Handle changes
uses: peter-evans/create-pull-request@v6.0.5
id: changes
with:
token: ${{secrets.AUTOMATION_TOKEN}}
commit-message: ${{steps.info.outputs.update-title}}
committer: ${{env.GIT_USER}}
add-paths: '*.h,*.c,*.c.in,LICENSE'
author: ${{env.GIT_USER}}
branch: auto/update-license
delete-branch: true
title: ${{steps.info.outputs.update-title}}
body: ${{steps.info.outputs.update-body}}
labels: auto
env:
GIT_USER: ${{secrets.AUTOMATION_USER}} <${{secrets.AUTOMATION_EMAIL}}>
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --squash "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{secrets.AUTOMATION_TOKEN}}