Skip to content

Merge pull request #3155 from weblate/weblate-jamulus-jamulus-app #37

Merge pull request #3155 from weblate/weblate-jamulus-jamulus-app

Merge pull request #3155 from weblate/weblate-jamulus-jamulus-app #37

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 "[email protected]"
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}