Skip to content

Commit

Permalink
Create update-license-year.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
ChanMeng666 authored Jan 7, 2025
1 parent 5b2c3dc commit 2ec9833
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions .github/workflows/update-license-year.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Update License Year

on:
schedule:
- cron: '0 0 1 1 *' # 每年 1 月 1 日运行
workflow_dispatch: # 允许手动触发

jobs:
update-license-year:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Update license year
run: |
CURRENT_YEAR=$(date +%Y)
# 使用 sed 更新年份
sed -i "s/Copyright (c) [0-9]* Chan Meng/Copyright (c) ${CURRENT_YEAR} Chan Meng/" LICENSE
- name: Check for changes
id: check_changes
run: |
git diff --quiet LICENSE || echo "changes=true" >> $GITHUB_OUTPUT
- name: Create Pull Request
if: steps.check_changes.outputs.changes == 'true'
uses: peter-evans/create-pull-request@v5
with:
commit-message: "chore: update license year to ${{ steps.get_year.outputs.year }}"
title: "chore: update license year"
body: "Automatically update license year to ${{ steps.get_year.outputs.year }}"
branch: "chore/update-license-year"
delete-branch: true

0 comments on commit 2ec9833

Please sign in to comment.