Files
MapLibreParticleLab/.github/workflows/pr-render-test-result.yml
2023-06-07 14:48:30 +02:00

66 lines
2.5 KiB
YAML

name: pr-upload-render-test-result
permissions:
pull-requests: write # This is required to leave a comment on the PR
id-token: write # This is required for requesting the AWS JWT
on:
workflow_run:
workflows: [linux-ci]
types:
- completed
jobs:
upload-render-test-result:
runs-on: ubuntu-22.04
if: github.event.workflow_run.event == 'pull_request'
steps:
# https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_run
- name: 'Download render-test-result artifact'
uses: actions/github-script@v6
with:
script: |
let allArtifacts = await github.rest.actions.listWorkflowRunArtifacts({
owner: context.repo.owner,
repo: context.repo.repo,
run_id: context.payload.workflow_run.id,
});
let matchArtifact = allArtifacts.data.artifacts.filter((artifact) => {
return artifact.name == "render-test-result"
})[0];
let download = await github.rest.actions.downloadArtifact({
owner: context.repo.owner,
repo: context.repo.repo,
artifact_id: matchArtifact.id,
archive_format: 'zip',
});
let fs = require('fs');
fs.writeFileSync(`${process.env.GITHUB_WORKSPACE}/render-test-result.zip`, Buffer.from(download.data));
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v2
with:
aws-region: us-west-2
role-to-assume: ${{ vars.OIDC_AWS_ROLE_TO_ASSUME }}
role-session-name: ${{ github.run_id }}
- name: 'Unzip render-test-result artifact'
run: unzip render-test-result.zip
- name: Upload render test results to S3
id: upload_render_test_results
run: |
aws s3 cp metrics/linux-gcc8-release-style.html \
s3://maplibre-native-test-artifacts/${{ github.run_id }}-linux-gcc8-release-style.html \
--expires "$(date -d '+30 days' --utc +'%Y-%m-%dT%H:%M:%SZ')"
- run: echo pr_number="$(cat ./pr_number)" >> "$GITHUB_ENV"
- name: 'Leave comment on PR with test results'
uses: marocchino/sticky-pull-request-comment@v2
with:
header: render-test-result
number: ${{ env.pr_number }}
message: |
Render test results at https://maplibre-native-test-artifacts.s3.eu-central-1.amazonaws.com/${{ github.run_id }}-linux-gcc8-release-style.html