Skip to content

Commit

Permalink
improve speed of PR builds + remove duplicated comments (#1090)
Browse files Browse the repository at this point in the history
Co-authored-by: Shane Osbourne <sosbourne@duckduckgo.com>
  • Loading branch information
shakyShane and Shane Osbourne authored Oct 4, 2024
1 parent 3790f24 commit 8da65a0
Showing 1 changed file with 33 additions and 14 deletions.
47 changes: 33 additions & 14 deletions .github/workflows/build-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,25 @@ permissions: write-all
jobs:
build:
if: github.event.action != 'closed'
runs-on: ubuntu-latest
runs-on: ubuntu-20.04

steps:
- name: Checkout repository
uses: actions/checkout@v3

- name: Set up Node.js
uses: actions/setup-node@v3
- name: Use Node.js 20
uses: actions/setup-node@v1
with:
node-version: 20.x
- uses: actions/cache@v4
with:
node-version: '20'
cache: 'npm'
path: ~/.npm
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-
- name: Install dependencies
run: npm install
run: npm ci --verbose

- name: Run build
run: npm run build
Expand All @@ -42,8 +47,18 @@ jobs:
echo "BRANCH_NAME=pr-releases/pr-${PR_NUMBER}" >> $GITHUB_ENV
echo "COMMIT_HASH=$(git rev-parse HEAD)" >> $GITHUB_ENV
- name: Post comment on PR
- name: Find Previous Comment
uses: peter-evans/find-comment@v2
id: find_comment
with:
issue-number: ${{ github.event.pull_request.number }}
comment-author: 'github-actions[bot]'
body-includes: 'Temporary Branch Update'
direction: last

- name: Create Comment Body
uses: actions/github-script@v7
id: create_body
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
Expand All @@ -61,15 +76,19 @@ jobs:
- **Branch Name**: [${branchName}](${branchUrl})
- **Commit Hash**: [${commitHash}](${commitUrl})
- **Install Command**: \`npm i github:duckduckgo/content-scope-scripts#${commitHash}\`
Please use the above install command to update to the latest version.
`;
`;
core.setOutput('comment_body', commentBody);
core.setOutput('pr_number', prNumber);
await github.rest.issues.createComment({
...context.repo,
issue_number: prNumber,
body: commentBody
});
- name: Create, or Update the Comment
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ github.event.pull_request.number }}
comment-id: ${{ steps.find_comment.outputs.comment-id }}
body: ${{ steps.create_body.outputs.comment_body }}
edit-mode: replace

clean_up:
if: github.event.action == 'closed'
Expand Down

0 comments on commit 8da65a0

Please sign in to comment.