Statoscope report publish #3022
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Statoscope report publish | |
on: | |
workflow_run: | |
workflows: ['Statoscope diff analyze'] | |
types: | |
- completed | |
jobs: | |
statoscope_publish_report: | |
name: Publish Statoscope Report | |
runs-on: ubuntu-latest | |
if: > | |
github.event.workflow_run.event == 'pull_request' && | |
(github.event.workflow_run.conclusion == 'success' || github.event.workflow_run.conclusion == 'failure') | |
permissions: | |
pull-requests: write | |
steps: | |
- name: Download Artifacts | |
uses: dawidd6/action-download-artifact@v3 | |
with: | |
workflow: ${{ github.event.workflow_run.workflow_id }} | |
run_id: ${{ github.event.workflow_run.id }} | |
- name: Extract data | |
id: extract-data | |
run: | | |
echo "REPORT_PR_NUMBER=$(cat statoscope-report/report-pr)" >> "$GITHUB_OUTPUT" | |
cp statoscope-report/result.json ./result.json | |
- name: Upload UI report to S3 | |
id: upload-to-s3 | |
run: | | |
aws --endpoint-url=${AWS_ENDPOINT} \ | |
s3 cp statoscope-report/index.html s3://${AWS_BUCKET}/${{ github.ref }}/; \ | |
echo "DOWNLOAD_LINK=$(aws --endpoint-url=${AWS_ENDPOINT} s3 presign s3://${AWS_BUCKET}/${{ github.ref }}/index.html)" >> $GITHUB_OUTPUT | |
env: | |
AWS_BUCKET: datalens-public-actions-reports | |
AWS_ENDPOINT: https://storage.yandexcloud.net | |
AWS_ACCESS_KEY_ID: ${{ secrets.S3_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.S3_SECRET_ACCESS_KEY }} | |
AWS_DEFAULT_REGION: ru-central1 | |
- name: Create comment text | |
uses: actions/github-script@v7 | |
id: create-comment-text | |
with: | |
script: | | |
const fs = require('fs'); | |
const downloadLink = "${{ steps.upload-to-s3.outputs.DOWNLOAD_LINK }}"; | |
const data = JSON.parse(fs.readFileSync('result.json', 'utf8')); | |
data.downloadLink = downloadLink; | |
return `**📦 Statoscope quick diff with main-branch:** | |
**⏱ Build time:** ${data.buildTime.diff.formatted} | |
**⚖️ Initial size:** ${data.initialSize.diff.formatted} | |
**🕵️ Validation errors:** ${data.validation.total} | |
Full Statoscope report could be found [here ↗️](${data.downloadLink})`; | |
result-encoding: string | |
- name: Create Comment | |
uses: marocchino/sticky-pull-request-comment@v2 | |
with: | |
header: statoscope-report | |
number: ${{ steps.extract-data.outputs.REPORT_PR_NUMBER }} | |
message: "${{steps.create-comment-text.outputs.result}}" | |