From 0a9260dbb5edc46d827192369a8d21a4cf0fe267 Mon Sep 17 00:00:00 2001 From: Rolf Bjarne Kvinge Date: Tue, 6 Dec 2022 07:50:31 +0100 Subject: [PATCH] [actions] Fix parsing problem in the changelog action. (#16940) Fixes this: SyntaxError: Unexpected identifier at new AsyncFunction () Error: Unhandled error: SyntaxError: Unexpected identifier at callAsyncFunction (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:13356:16) at main (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:13452:26) at Module.858 (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:13429:1) at __webpack_require__ (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:24:31) at startup (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:43:19) at /home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:49:18 at Object. (/home/runner/work/_actions/actions/github-script/v6.3.3/dist/index.js:52:10) at Module._compile (node:internal/modules/cjs/loader:1101:14) at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) by not storing the changelog entry in an environment variable between tasks, but instead store it on disk. --- .github/workflows/maestro-changelog.yml | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/.github/workflows/maestro-changelog.yml b/.github/workflows/maestro-changelog.yml index 330ad82f10ae..2de99a009ecb 100644 --- a/.github/workflows/maestro-changelog.yml +++ b/.github/workflows/maestro-changelog.yml @@ -16,20 +16,20 @@ jobs: dotnet run https://github.com/$GITHUB_REPOSITORY/pull/${GITHUB_REF_NAME/\/*/} > changelog.txt 2>&1 # need to replace newlines with actual "\n" - rm -f changelog2.txt - echo "CHANGELOG_MESSAGE<> changelog2.txt - cat changelog.txt | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' >> changelog2.txt - echo EOF >> changelog2.txt - cat changelog2.txt + CHANGELOG_FILE=changelog2.txt + rm -f "$CHANGELOG_FILE" + cat changelog.txt | sed -e ':a' -e 'N' -e '$!ba' -e 's/\n/\\n/g' >> "$CHANGELOG_FILE" + cat "$CHANGELOG_FILE" - # export the changelog message - cat changelog2.txt >> $GITHUB_ENV + cp "$CHANGELOG_FILE" /tmp/changelog.txt - name: 'Add changelog' uses: actions/github-script@v6.3.3 with: github-token: ${{secrets.GITHUB_TOKEN}} script: | + const fs = require('fs'); + const changelog_message = fs.readFileSync('/tmp/changelog.txt', 'utf8'); // check if we've already added a changelog to this PR, and if so, update that comment, otherwise add a new comment var commentId = "" await github.paginate (github.rest.issues.listComments, @@ -48,13 +48,13 @@ jobs: owner: context.repo.owner, repo: context.repo.repo, issue_number: context.issue.number, - body: '${{ env.CHANGELOG_MESSAGE }}' + body: changelog_message }) } else { github.rest.issues.updateComment({ owner: context.repo.owner, repo: context.repo.repo, comment_id: commentId, - body: '${{ env.CHANGELOG_MESSAGE }}' + body: changelog_message }) }