From ce673e3bb8546f682ee0b7eafad94cec59932cf2 Mon Sep 17 00:00:00 2001 From: Sebastian Ullrich Date: Sun, 16 Oct 2022 12:20:10 +0200 Subject: [PATCH] chore: add Update changelog action --- .github/workflows/changelog.yml | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 .github/workflows/changelog.yml diff --git a/.github/workflows/changelog.yml b/.github/workflows/changelog.yml new file mode 100644 index 0000000000..cbc526a6ee --- /dev/null +++ b/.github/workflows/changelog.yml @@ -0,0 +1,30 @@ +name: add PR to changelog + +on: + # needs read/write GH token, do *not* execute arbitrary code from PR + pull_request_target: + types: [closed] + +jobs: + update-changelog: + if: | + github.event.pull_request.merged == true && + contains(github.event.pull_request.labels.*.name, 'changelog') && + github.base_ref == 'master' + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Update changelog + run: | + set -euxo pipefail + escaped_link=$(sed -e 's/[\/&]/\\&/g' <<'EOF' + [${{ github.event.pull_request.title}}](${{ github.event.pull_request.html_url }}) + EOF + ) + # insert link below first dashes line (https://stackoverflow.com/a/9453461/161659) + sed -i "0,/^---*/s/^---*/\0\n\n* $escaped_link./" RELEASES.md + # commit as github-actions bot (https://github.com/orgs/community/discussions/26560#discussioncomment-3252339) + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git config user.name "github-actions[bot]" + git commit -i RELEASES.md -m "update changelog" + git push