Skip to content

Commit

Permalink
update PR builds action
Browse files Browse the repository at this point in the history
  • Loading branch information
jeanfbrito committed Aug 23, 2024
1 parent 8f7567f commit 43f2cd1
Showing 1 changed file with 44 additions and 5 deletions.
49 changes: 44 additions & 5 deletions .github/workflows/pull-request-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ on:
- master
- develop

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref }}
cancel-in-progress: true

jobs:
build:
if: contains(github.event.pull_request.labels.*.name, 'build-artifacts')
strategy:
fail-fast: false
matrix:
Expand All @@ -21,17 +26,17 @@ jobs:
run: git config --global core.autocrlf false

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
fetch-depth: 0

- name: Setup Node 20.10.0
uses: actions/setup-node@v3
- name: Setup Node 20.14.0
uses: actions/setup-node@v4
with:
node-version: '20.10.0'
node-version: '20.14.0'

- name: Setup node_modules cache
uses: actions/cache@v3
uses: actions/cache@v4
with:
path: '**/node_modules'
key: ${{ runner.os }}-modules-${{ hashFiles('**/yarn.lock') }}
Expand Down Expand Up @@ -86,3 +91,37 @@ jobs:
dist/rocketchat-*.pkg
dist/rocketchat-*.exe
dist/rocketchat-*.snap
- name: Get Artifact URL
id: get-artifact-url
uses: actions/github-script@v6
with:
script: |
const owner = context.repo.owner;
const repo = context.repo.repo;
const runId = context.runId;
const artifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner,
repo,
run_id: runId
});
const artifact = artifacts.data.artifacts.find(a => a.name === '${{ runner.os }} Artifacts');
if (artifact) {
const url = `https://github.com/${owner}/${repo}/actions/runs/${runId}/artifacts/${artifact.id}`;
core.setOutput('artifact_url', url);
} else {
core.setFailed(`Artifact not found for ${artifact.name}`);
}
- name: Post PR Comment with the Artifact link
if: steps.get-artifact-url.outputs.artifact_url != ''
uses: marocchino/sticky-pull-request-comment@v2
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
message: |
### [${{ runner.os }} installer download](${{ steps.get-artifact-url.outputs.artifact_url }})
header: '### Artifact for ${{ runner.os }}'
recreate: true
append: false

0 comments on commit 43f2cd1

Please sign in to comment.