Skip to content

Bump peter-evans/create-pull-request from 6.0.3 to 6.0.5 (#477) #58

Bump peter-evans/create-pull-request from 6.0.3 to 6.0.5 (#477)

Bump peter-evans/create-pull-request from 6.0.3 to 6.0.5 (#477) #58

name: Update License
on:
push:
branches: main
paths: .github/workflows/update-license.yml
schedule:
- cron: '0 0 1 1 *'
workflow_dispatch:
permissions:
contents: read
concurrency: update-license
jobs:
update-license:
name: Update License
runs-on: ubuntu-latest
timeout-minutes: 5
env:
REGEX: ^(((\/\/|#) )?Copyright \(c\) )[0-9]{4}( Devon Powell)$
steps:
- name: Checkout
uses: actions/checkout@v4.1.4
- name: Determine info
shell: bash
id: info
run: |
OLD_YEAR=$(grep -oEi "$REGEX" LICENSE | grep -oEi '[0-9]{4}')
NEW_YEAR=$(date +%Y)
UPDATE_TITLE="Bump license year from $OLD_YEAR to $NEW_YEAR"
UPDATE_BODY="$UPDATE_TITLE."
echo "::set-output name=license-year::$NEW_YEAR"
echo "::set-output name=update-title::$UPDATE_TITLE"
echo "::set-output name=update-body::$UPDATE_BODY"
- name: Update licenses
run: >
find . -type f -not -path './.git/*' -and
-iregex '^.*\(\.\(h\|c\|c\.in\)\|LICENSE\)$'
-exec sed -i -E "s/$REGEX/\1$YEAR\4/" {} \;
env:
YEAR: ${{steps.info.outputs.license-year}}
- name: Handle changes
uses: peter-evans/create-pull-request@v6.0.5
id: changes
with:
token: ${{secrets.AUTOMATION_TOKEN}}
commit-message: ${{steps.info.outputs.update-title}}
committer: ${{env.GIT_USER}}
add-paths: '*.h,*.c,*.c.in,LICENSE'
author: ${{env.GIT_USER}}
branch: auto/update-license
delete-branch: true
title: ${{steps.info.outputs.update-title}}
body: ${{steps.info.outputs.update-body}}
labels: auto
env:
GIT_USER: ${{secrets.AUTOMATION_USER}} <${{secrets.AUTOMATION_EMAIL}}>
- name: Enable auto-merge
if: steps.changes.outputs.pull-request-operation == 'created'
run: gh pr merge --auto --squash "$PULL_REQUEST_URL"
env:
PULL_REQUEST_URL: ${{steps.changes.outputs.pull-request-url}}
GITHUB_TOKEN: ${{secrets.AUTOMATION_TOKEN}}