@@ -8,21 +8,26 @@ permissions: write-all
88
99jobs :
1010 build :
11- if : github.event.pull_request.draft == false && github.event. action != 'closed'
12- runs-on : ubuntu-latest
11+ if : github.event.action != 'closed'
12+ runs-on : ubuntu-20.04
1313
1414 steps :
1515 - name : Checkout repository
1616 uses : actions/checkout@v3
1717
18- - name : Set up Node.js
19- uses : actions/setup-node@v3
18+ - name : Use Node.js 20
19+ uses : actions/setup-node@v1
20+ with :
21+ node-version : 20.x
22+ - uses : actions/cache@v4
2023 with :
21- node-version : ' 20'
22- cache : ' npm'
24+ path : ~/.npm
25+ key : ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
26+ restore-keys : |
27+ ${{ runner.os }}-node-
2328
2429 - name : Install dependencies
25- run : npm install
30+ run : npm ci --verbose
2631
2732 - name : Run build
2833 run : npm run build
4247 echo "BRANCH_NAME=pr-releases/pr-${PR_NUMBER}" >> $GITHUB_ENV
4348 echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
4449
45- - name : Post comment on PR
50+ - name : Find Previous Comment
51+ uses : peter-evans/find-comment@v2
52+ id : find_comment
53+ with :
54+ issue-number : ${{ github.event.pull_request.number }}
55+ comment-author : ' github-actions[bot]'
56+ body-includes : ' Temporary Branch Update'
57+ direction : last
58+
59+ - name : Create Comment Body
4660 uses : actions/github-script@v7
61+ id : create_body
4762 with :
4863 github-token : ${{ secrets.GITHUB_TOKEN }}
4964 script : |
@@ -61,15 +76,19 @@ jobs:
6176 - **Branch Name**: [${branchName}](${branchUrl})
6277 - **Commit Hash**: [${commitHash}](${commitUrl})
6378 - **Install Command**: \`npm i github:duckduckgo/content-scope-scripts#${commitHash}\`
64-
79+
6580 Please use the above install command to update to the latest version.
66- `;
81+ `;
82+ core.setOutput('comment_body', commentBody);
83+ core.setOutput('pr_number', prNumber);
6784
68- await github.rest.issues.createComment({
69- ...context.repo,
70- issue_number: prNumber,
71- body: commentBody
72- });
85+ - name : Create, or Update the Comment
86+ uses : peter-evans/create-or-update-comment@v2
87+ with :
88+ issue-number : ${{ github.event.pull_request.number }}
89+ comment-id : ${{ steps.find_comment.outputs.comment-id }}
90+ body : ${{ steps.create_body.outputs.comment_body }}
91+ edit-mode : replace
7392
7493 clean_up :
7594 if : github.event.action == 'closed'
0 commit comments