-
Notifications
You must be signed in to change notification settings - Fork 224
59 lines (56 loc) · 2.05 KB
/
update-copyright-notices.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
name: Update copyright notices
permissions: {}
on:
push:
branches:
- main
pull_request:
types:
- closed
jobs:
check-and-update-copyright-notices:
if: >-
github.repository_owner == 'jamulussoftware' &&
github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- run: ./tools/update-copyright-notices.sh
- env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git config --global user.email "actions@github.com"
git config --global user.name "github-actions[bot]"
pr_branch=updateCopyrightNotices
git checkout -b ${pr_branch}
git add .
git commit -m "AUTO: Update copyright notices for $(date +%Y)" || exit 0
git push origin "+${pr_branch}"
existing_pr=$(gh pr list --head "${pr_branch}" --json number --jq '.[].number')
if [[ $existing_pr ]]; then
gh pr comment "${existing_pr}" --body "PR has been updated by tools/update-copyright-notices.sh."
else
body=$'This automated Pull Request updates the copyright notices throughout the source.\n\n'
body="${body}This PR is the result of a tools/update-copyright-notices.sh run."$'\n\n'
body="${body}CHANGELOG: SKIP"
gh pr create --base main --head "${pr_branch}" --title "Update copyright notice(s) for $(date +%Y)" --body "${body}"
fi
delete-old-pr-branch:
if: >-
github.repository_owner == 'jamulussoftware' &&
github.event_name == 'pull_request' &&
startsWith(github.event.pull_request.head.label, 'jamulussoftware:updateCopyrightNotices')
runs-on: ubuntu-latest
permissions:
pull-requests: write
contents: write
steps:
- uses: actions/checkout@v3
- env:
pr_branch: ${{ github.event.pull_request.head.ref }}
run: |
[[ ${pr_branch} == updateCopyrightNotices ]] || exit 1
git push origin :${pr_branch}