-
Notifications
You must be signed in to change notification settings - Fork 18
58 lines (48 loc) · 1.73 KB
/
update-copyright-headers.yaml
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
name: Update Copyright Headers
on:
# Runs at 00:00 UTC on Jan 4th or via manual trigger
schedule:
- cron: '0 0 4 1 *'
workflow_dispatch:
inputs:
newYear:
description: "Desired year to update to (e.g., 2025). If not provided, will auto-detect."
required: false
jobs:
update-headers:
runs-on: ubuntu-latest
steps:
- name: Check out repository
uses: actions/checkout@v3
- name: Determine years for update
id: determine-years
run: |
INPUT_YEAR="${{ github.event.inputs.newYear }}"
if [ -z "$INPUT_YEAR" ]; then
CURRENT_YEAR="$(date +'%Y')"
echo "No 'newYear' input. Using current year: ${CURRENT_YEAR}"
else
CURRENT_YEAR="$INPUT_YEAR"
echo "Received user input. Updating to: ${CURRENT_YEAR}"
fi
echo "CURRENT_YEAR=$CURRENT_YEAR" >> $GITHUB_ENV
- name: Bump ending year in QIIME 2 headers
run: |
source $GITHUB_ENV
echo "Will update any QIIME 2 header years in [2015..$((CURRENT_YEAR-1))] to $CURRENT_YEAR"
for OLD_YEAR in $(seq 2015 $((CURRENT_YEAR - 1))); do
find . -type f -exec \
sed -i -E "s/(Copyright \(c\) [0-9]{4})-${OLD_YEAR}, QIIME 2/\1-${CURRENT_YEAR}, QIIME 2/g" {} +
done
- name: Commit and push changes
run: |
git config --global user.name "q2d2"
git config --global user.email "[email protected]"
if [ -n "$(git status --porcelain)" ]; then
git add .
git commit -m "Auto-update copyright year to $CURRENT_YEAR"
git push
else
echo "No changes to commit."
exit 0
fi