Update License #22
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
name: Update License | |
on: | |
push: | |
branches: main | |
paths: .github/workflows/update-license.yml | |
schedule: | |
- cron: '0 0 1 1 *' | |
permissions: | |
contents: write | |
concurrency: update-license | |
jobs: | |
update-license: | |
name: Update License | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v4.1.1 | |
with: | |
persist-credentials: false | |
- name: Determine year | |
id: year | |
run: echo "value=$(date +%Y)" >> $GITHUB_OUTPUT | |
- name: Update LICENSE | |
run: sed -i -E "s/$REGEX/\1${{steps.year.outputs.value}}\2/" LICENSE | |
env: | |
REGEX: ^(Copyright \(c\) )[0-9]{4}( Devon Powell)$ | |
- name: Check for changes | |
id: changes | |
run: | | |
git diff --exit-code LICENSE || echo '::set-output name=exist::true' | |
- name: Push commit | |
if: steps.changes.outputs.exist | |
run: | | |
git config user.name $COMMIT_USERNAME | |
git config user.email $COMMIT_EMAIL | |
git add LICENSE | |
git commit -m 'Update license year to ${{steps.year.outputs.value}}' | |
CREDENTIALS="x-access-token:$GITHUB_TOKEN" | |
URL="https://$CREDENTIALS@github.com/${{github.repository}}.git" | |
git remote set-url origin $URL | |
git push origin main | |
env: | |
GITHUB_TOKEN: ${{secrets.PERSONAL_GITHUB_TOKEN}} | |
COMMIT_USERNAME: github-actions[bot] | |
COMMIT_EMAIL: 41898282+github-actions[bot]@users.noreply.github.com |