Skip to content

Commit 0d7c32b

Browse files
committed
Add automated copyright year update workflow
- Runs automatically on January 1st every year - Can be manually triggered via workflow_dispatch - Creates a PR with copyright year updates instead of direct push - Tested locally: successfully updates all .sh files from 2025 to 2026
1 parent e1bb657 commit 0d7c32b

File tree

1 file changed

+51
-0
lines changed

1 file changed

+51
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
name: 'Update Copyright Year'
2+
3+
on:
4+
schedule:
5+
# Run on January 1st at 00:00 UTC every year
6+
- cron: '0 0 1 1 *'
7+
workflow_dispatch: # Allow manual trigger
8+
9+
jobs:
10+
update-copyright:
11+
name: Update Copyright Year to Current Year
12+
runs-on: ubuntu-latest
13+
permissions:
14+
contents: write
15+
pull-requests: write
16+
steps:
17+
- name: Checkout repository
18+
uses: actions/checkout@v4
19+
20+
- name: Get current year
21+
id: year
22+
run: echo "current_year=$(date +'%Y')" >> $GITHUB_OUTPUT
23+
24+
- name: Get previous year
25+
id: prev_year
26+
run: echo "previous_year=$(date -d 'last year' +'%Y')" >> $GITHUB_OUTPUT
27+
28+
- name: Update copyright year in all .sh files
29+
run: |
30+
find . -type f -name "*.sh" -exec sed -i 's/© - ${{ steps.prev_year.outputs.previous_year }}/© - ${{ steps.year.outputs.current_year }}/g' {} \;
31+
32+
- name: Check for changes
33+
id: verify_diff
34+
run: |
35+
git diff --quiet . || echo "changed=true" >> $GITHUB_OUTPUT
36+
37+
- name: Create Pull Request
38+
if: steps.verify_diff.outputs.changed == 'true'
39+
uses: peter-evans/create-pull-request@v6
40+
with:
41+
commit-message: 'Update copyright year to ${{ steps.year.outputs.current_year }}'
42+
title: 'Update copyright year to ${{ steps.year.outputs.current_year }}'
43+
body: |
44+
Automated update of copyright year from ${{ steps.prev_year.outputs.previous_year }} to ${{ steps.year.outputs.current_year }}.
45+
46+
Updated all `© - ${{ steps.prev_year.outputs.previous_year }}` to `© - ${{ steps.year.outputs.current_year }}` in .sh files.
47+
branch: 'automated/copyright-${{ steps.year.outputs.current_year }}'
48+
delete-branch: true
49+
labels: |
50+
automated
51+
maintenance

0 commit comments

Comments
 (0)