Skip to content

Commit 7b0c2b4

Browse files
authored
chore: fix Bump License Year workflow (#23)
1 parent 4d0d5f8 commit 7b0c2b4

File tree

1 file changed

+19
-43
lines changed

1 file changed

+19
-43
lines changed

.github/workflows/bump-license-year.yml

Lines changed: 19 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -2,70 +2,46 @@ name: Bump License Year
22

33
on:
44
schedule:
5-
- cron: '0 0 1 1 *'
5+
- cron: 0 0 1 1 *
66
workflow_dispatch:
77

8-
permissions:
9-
contents: write
10-
pull-requests: write
11-
128
jobs:
13-
bump-year:
9+
bump-license-year:
1410
runs-on: ubuntu-latest
1511

12+
permissions:
13+
contents: write
14+
pull-requests: write
15+
1616
steps:
1717
- name: Checkout
1818
uses: actions/checkout@v4
1919

2020
- name: Set the current year
2121
run: |
2222
echo "CURRENT_YEAR=$(date +'%Y')" >> $GITHUB_ENV
23-
echo "BRANCH_NAME=bump-license-year-${CURRENT_YEAR}" >> $GITHUB_ENV
24-
25-
- name: Configure Git
26-
run: |
27-
git config --global user.name "github-actions[bot]"
28-
git config --global user.email "github-actions[bot]@users.noreply.github.com"
2923
3024
- name: Update license year
3125
run: |
3226
OLD_YEAR=$(grep -oP '\d{4}' LICENSE | tail -n 1)
27+
28+
echo "Old year: $OLD_YEAR"
29+
echo "Current year: ${CURRENT_YEAR}"
30+
3331
if [ "$OLD_YEAR" != "${CURRENT_YEAR}" ]; then
3432
sed -i "s/$OLD_YEAR/${CURRENT_YEAR}/g" LICENSE
3533
fi
3634
37-
- name: Check for changes
38-
id: changes_check
39-
run: |
40-
if git diff --quiet; then
41-
echo "No changes detected."
42-
echo "CHANGES_DETECTED=false" >> $GITHUB_ENV
43-
else
44-
echo "Changes detected."
45-
echo "CHANGES_DETECTED=true" >> $GITHUB_ENV
46-
47-
- name: Create new branch
48-
if: env.CHANGES_DETECTED == 'true'
49-
run: |
50-
git checkout -b ${BRANCH_NAME}
51-
52-
- name: Commit changes
53-
if: env.CHANGES_DETECTED == 'true'
54-
run: |
55-
git add LICENSE
56-
git commit -m "chore: bump license year to ${CURRENT_YEAR}"
57-
58-
- name: Push changes
59-
if: env.CHANGES_DETECTED == 'true'
60-
run: git push --set-upstream origin ${BRANCH_NAME}
61-
env:
62-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
63-
6435
- name: Create Pull Request
65-
if: env.CHANGES_DETECTED == 'true'
66-
uses: actions/create-pull-request@v7
36+
uses: peter-evans/create-pull-request@v7
6737
with:
6838
token: ${{ secrets.GITHUB_TOKEN }}
69-
branch: ${BRANCH_NAME}
70-
title: 'chore: bump license year to ${CURRENT_YEAR}'
39+
commit-message: |
40+
chore: bump license year to ${{ env.CURRENT_YEAR }}
41+
sign-commits: true
42+
title: |
43+
Bump license year to ${{ env.CURRENT_YEAR }}
44+
body: |
45+
- Bump license year to ${{ env.CURRENT_YEAR }}
46+
branch: bump-license-year-${{ env.CURRENT_YEAR }}
7147
base: main

0 commit comments

Comments
 (0)