Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
71 changes: 71 additions & 0 deletions .github/workflows/bump-license-year.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,71 @@
name: Bump License Year

on:
schedule:
- cron: '0 0 1 1 *'
workflow_dispatch:

permissions:
contents: write
pull-requests: write

jobs:
bump-year:
runs-on: ubuntu-latest

steps:
- name: Checkout
uses: actions/checkout@v4

- name: Set the current year
run: |
echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV
echo "BRANCH_NAME=bump-license-year-${CURRENT_YEAR}" >> $GITHUB_ENV

- name: Configure Git
run: |
git config --global user.name "github-actions[bot]"
git config --global user.email "github-actions[bot]@users.noreply.github.com"

- name: Update license year
run: |
OLD_YEAR=$(grep -oP '\d{4}' LICENSE | tail -n 1)
if [ "$OLD_YEAR" != "${CURRENT_YEAR}" ]; then
sed -i "s/$OLD_YEAR/${CURRENT_YEAR}/g" LICENSE
fi

- name: Check for changes
id: changes_check
run: |
if git diff --quiet; then
echo "No changes detected."
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
else
echo "Changes detected."
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV

- name: Create new branch
if: env.CHANGES_DETECTED == 'true'
run: |
git checkout -b ${BRANCH_NAME}

- name: Commit changes
if: env.CHANGES_DETECTED == 'true'
run: |
git add LICENSE
git commit -m "chore: bump license year to ${CURRENT_YEAR}"

- name: Push changes
if: env.CHANGES_DETECTED == 'true'
run: git push --set-upstream origin ${BRANCH_NAME}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Create Pull Request
if: env.CHANGES_DETECTED == 'true'
uses: actions/create-pull-request@v7
with:
token: ${{ secrets.GITHUB_TOKEN }}
branch: ${BRANCH_NAME}
title: 'chore: bump license year to ${CURRENT_YEAR}'
base: main