Skip to content

Commit

Permalink
[actions] Fix parsing problem in the changelog action. (#16940)
Browse files Browse the repository at this point in the history
Fixes this:

    SyntaxError: Unexpected identifier
        at new AsyncFunction (<anonymous>)
    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.<anonymous> (/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.
  • Loading branch information
rolfbjarne committed Dec 6, 2022
1 parent 94bdee0 commit 0a9260d
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions .github/workflows/maestro-changelog.yml
Expand Up @@ -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<<EOF" >> 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,
Expand All @@ -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
})
}

0 comments on commit 0a9260d

Please sign in to comment.