Commit 0895c09 1 parent 7c59baa commit 0895c09 Copy full SHA for 0895c09
File tree 1 file changed +58
-0
lines changed
1 file changed +58
-0
lines changed Original file line number Diff line number Diff line change
1
+ name : Update Copyright Headers
2
+
3
+ on :
4
+ # Runs at 00:00 UTC on Jan 3rd or via manual trigger
5
+ schedule :
6
+ - cron : ' 0 0 3 1 *'
7
+ workflow_dispatch :
8
+ inputs :
9
+ newYear :
10
+ description : " Desired year to update to (e.g., 2025). If not provided, will auto-detect."
11
+ required : false
12
+
13
+ jobs :
14
+ update-headers :
15
+ runs-on : ubuntu-latest
16
+ steps :
17
+ - name : Check out repository
18
+ uses : actions/checkout@v3
19
+
20
+ - name : Determine years for update
21
+ id : determine-years
22
+ run : |
23
+ INPUT_YEAR="${{ github.event.inputs.newYear }}"
24
+
25
+ if [ -z "$INPUT_YEAR" ]; then
26
+ CURRENT_YEAR="$(date +'%Y')"
27
+ echo "No 'newYear' input. Using current year: ${CURRENT_YEAR}"
28
+ else
29
+ CURRENT_YEAR="$INPUT_YEAR"
30
+ echo "Received user input. Updating to: ${CURRENT_YEAR}"
31
+ fi
32
+
33
+ echo "CURRENT_YEAR=$CURRENT_YEAR" >> $GITHUB_ENV
34
+
35
+ - name : Bump ending year in QIIME 2 headers
36
+ run : |
37
+ source $GITHUB_ENV
38
+
39
+ echo "Will update any QIIME 2 header years in [2015..$((CURRENT_YEAR-1))] to $CURRENT_YEAR"
40
+
41
+ for OLD_YEAR in $(seq 2015 $((CURRENT_YEAR - 1))); do
42
+ find . -type f -exec \
43
+ sed -i -E "s/(Copyright \(c\) [0-9]{4})-${OLD_YEAR}, QIIME 2/\1-${CURRENT_YEAR}, QIIME 2/g" {} +
44
+ done
45
+
46
+ - name : Commit and push changes
47
+ run : |
48
+ git config --global user.name "q2d2"
49
+ git config --global user.email "[email protected] "
50
+
51
+ if [ -n "$(git status --porcelain)" ]; then
52
+ git add .
53
+ git commit -m "Auto-update copyright year to $CURRENT_YEAR"
54
+ git push
55
+ else
56
+ echo "No changes to commit."
57
+ exit 0
58
+ fi
You can’t perform that action at this time.
0 commit comments