diff --git a/.github/workflows/pull-request-build.yml b/.github/workflows/pull-request-build.yml index 9f8725853..07441fa96 100644 --- a/.github/workflows/pull-request-build.yml +++ b/.github/workflows/pull-request-build.yml @@ -91,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