-
-
Notifications
You must be signed in to change notification settings - Fork 18
29 lines (27 loc) · 965 Bytes
/
license_update.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
name: "License Update"
on:
schedule:
- cron: '05 00 1 1 *'
jobs:
license_update:
name: License Update
runs-on: ubuntu-latest
steps:
- name: Repository Checkout
uses: actions/checkout@v2
- name: Year Replacement
env:
LICENSE_REGEX: 2019-\d{4}
LICENSE_FILE: LICENSE.md
run: |
CURRENT_YEAR=$(date +%Y)
grep -P "$LICENSE_REGEX" "$LICENSE_FILE"
PATTERN=$(grep -Poh "$LICENSE_REGEX" "$LICENSE_FILE")
sed -i "s/$PATTERN/2019-$CURRENT_YEAR/g" "$LICENSE_FILE"
grep -P "$LICENSE_REGEX" "$LICENSE_FILE"
git remote set-url origin "https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository }}"
git config --local user.name "${{ secrets.BOT_USERNAME }}"
git config --local user.email "${{ secrets.BOT_EMAIL }}"
git add --a
git diff-index --quiet HEAD || git commit -m "License $CURRENT_YEAR"
git push