-
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
3b49333
commit 87434d8
Showing
1 changed file
with
72 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
name: Update License Year | ||
|
||
on: | ||
schedule: | ||
- cron: '0 0 1 1 *' # 每年1月1日运行 | ||
workflow_dispatch: # 允许手动触发 | ||
|
||
jobs: | ||
update-license-year: | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: write | ||
pull-requests: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
fetch-depth: 0 | ||
|
||
- name: Update year in LICENSE | ||
run: | | ||
CURRENT_YEAR=$(date +%Y) | ||
echo "CURRENT_YEAR=$CURRENT_YEAR" >> $GITHUB_ENV | ||
# 调试输出 | ||
echo "Current content of LICENSE file:" | ||
cat LICENSE | ||
echo "Current year: $CURRENT_YEAR" | ||
# 更新年份 - 支持多种格式 | ||
if [ -f LICENSE ]; then | ||
# 更新 "Copyright (c) YYYY" 格式 | ||
sed -i -E "s/Copyright \(c\) [0-9]{4}/Copyright (c) ${CURRENT_YEAR}/" LICENSE | ||
# 更新 "Copyright (c) YYYY-YYYY" 格式 | ||
sed -i -E "s/Copyright \(c\) [0-9]{4}-[0-9]{4}/Copyright (c) ${CURRENT_YEAR}/" LICENSE | ||
# 更新 "Copyright YYYY" 格式 | ||
sed -i -E "s/Copyright [0-9]{4}/Copyright ${CURRENT_YEAR}/" LICENSE | ||
echo "Updated content of LICENSE file:" | ||
cat LICENSE | ||
else | ||
echo "LICENSE file not found!" | ||
fi | ||
- name: Check for changes | ||
id: changes | ||
run: | | ||
if git diff --quiet; then | ||
echo "No changes detected" | ||
echo "changed=false" >> $GITHUB_OUTPUT | ||
else | ||
echo "Changes detected" | ||
echo "changed=true" >> $GITHUB_OUTPUT | ||
git diff | ||
fi | ||
- name: Create Pull Request | ||
if: steps.changes.outputs.changed == 'true' | ||
uses: peter-evans/create-pull-request@v7 | ||
with: | ||
token: ${{ secrets.GITHUB_TOKEN }} | ||
commit-message: "chore: update license year to ${{ env.CURRENT_YEAR }}" | ||
title: "chore: update license year to ${{ env.CURRENT_YEAR }}" | ||
body: | | ||
Automated changes: | ||
- Updated copyright year in LICENSE file to current year (${{ env.CURRENT_YEAR }}) | ||
Please review the changes and merge if appropriate. | ||
branch: update-license-year | ||
base: main | ||
delete-branch: true |