|
| 1 | +name: Publish a pull request report |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_call: |
| 5 | + inputs: |
| 6 | + report: |
| 7 | + type: string |
| 8 | + required: true |
| 9 | + artifact: |
| 10 | + type: string |
| 11 | + required: true |
| 12 | + filename: |
| 13 | + type: string |
| 14 | + required: true |
| 15 | + title: |
| 16 | + type: string |
| 17 | + default: "" |
| 18 | + full-report-artifact: |
| 19 | + type: string |
| 20 | + default: "" |
| 21 | + secrets: |
| 22 | + KV_API_URL: |
| 23 | + required: true |
| 24 | + STS_API_URL: |
| 25 | + required: true |
| 26 | + |
| 27 | +permissions: {} |
| 28 | + |
| 29 | +env: |
| 30 | + UV_LOCKED: 1 |
| 31 | + |
| 32 | +jobs: |
| 33 | + publish: |
| 34 | + if: >- |
| 35 | + github.repository == 'astral-sh/ruff' && |
| 36 | + github.event_name == 'pull_request' && |
| 37 | + github.event.pull_request.head.repo.full_name == github.repository |
| 38 | + runs-on: github-ubuntu-24.04-x86_64-2 |
| 39 | + timeout-minutes: 10 |
| 40 | + environment: automations |
| 41 | + permissions: |
| 42 | + contents: read |
| 43 | + id-token: write |
| 44 | + concurrency: |
| 45 | + group: pull-request-report-${{ github.event.pull_request.number }}-${{ inputs.report }} |
| 46 | + cancel-in-progress: false |
| 47 | + queue: max |
| 48 | + steps: |
| 49 | + - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 |
| 50 | + with: |
| 51 | + repository: ${{ job.workflow_repository }} |
| 52 | + ref: ${{ job.workflow_sha }} |
| 53 | + sparse-checkout: scripts |
| 54 | + persist-credentials: false |
| 55 | + - uses: astral-sh/setup-uv@1c37ad07a6a961277cf70c0d37d6f313000f5884 # v10.3.0 |
| 56 | + with: |
| 57 | + # renovate: datasource=github-release-attachments depName=astral-sh/uv |
| 58 | + version: "0.13.4" |
| 59 | + checksum: "2b428396f12572d4429cf210ca234dd599a33b3af0958a4d5ed569d63e3f344f" |
| 60 | + enable-cache: false |
| 61 | + - name: Read the stored comment ID |
| 62 | + uses: astral-sh/github-actions/key-value-store/get@9ece8e1afa7e9485a0bc35c40e34e1fa495ae454 |
| 63 | + with: |
| 64 | + service-url: ${{ secrets.KV_API_URL }} |
| 65 | + scope: pull-request |
| 66 | + key: report-comment-${{ inputs.report }} |
| 67 | + path: ${{ runner.temp }}/report-comment-id-${{ github.run_id }}-${{ github.run_attempt }} |
| 68 | + - name: Get a report publishing token |
| 69 | + id: token |
| 70 | + uses: open-security-tools/ost-simple-sts@9e012247e07c39080fb6a832dbfbcfeacebc19c4 |
| 71 | + with: |
| 72 | + exchange-url: ${{ secrets.STS_API_URL }}/exchange |
| 73 | + audience: ${{ secrets.STS_API_URL }} |
| 74 | + repository: astral-sh/ruff |
| 75 | + permissions: | |
| 76 | + actions: read |
| 77 | + pull_requests: write |
| 78 | + - name: Publish the report |
| 79 | + id: publish |
| 80 | + env: |
| 81 | + GH_TOKEN: ${{ steps.token.outputs.token }} |
| 82 | + RUN_ID: ${{ github.run_id }} |
| 83 | + RUN_ATTEMPT: ${{ github.run_attempt }} |
| 84 | + WORKFLOW_REF: ${{ github.workflow_ref }} |
| 85 | + REPORT: ${{ inputs.report }} |
| 86 | + REPORT_ARTIFACT: ${{ inputs.artifact }} |
| 87 | + REPORT_FILENAME: ${{ inputs.filename }} |
| 88 | + REPORT_TITLE: ${{ inputs.title }} |
| 89 | + FULL_REPORT_ARTIFACT: ${{ inputs.full-report-artifact }} |
| 90 | + PULL_REQUEST: ${{ github.event.pull_request.number }} |
| 91 | + COMMENT_ID_FILE: ${{ runner.temp }}/report-comment-id-${{ github.run_id }}-${{ github.run_attempt }} |
| 92 | + run: >- |
| 93 | + uv run --script scripts/publish_pr_report.py |
| 94 | + --run-id "$RUN_ID" --run-attempt "$RUN_ATTEMPT" |
| 95 | + --workflow-ref "$WORKFLOW_REF" |
| 96 | + --report "$REPORT" --pull-request "$PULL_REQUEST" |
| 97 | + --artifact "$REPORT_ARTIFACT" --filename "$REPORT_FILENAME" |
| 98 | + --title "$REPORT_TITLE" --full-report-artifact "$FULL_REPORT_ARTIFACT" |
| 99 | + --comment-id-file "$COMMENT_ID_FILE" |
| 100 | + - name: Store the comment ID |
| 101 | + if: steps.publish.outputs.comment-id != '' |
| 102 | + uses: astral-sh/github-actions/key-value-store/put@9ece8e1afa7e9485a0bc35c40e34e1fa495ae454 |
| 103 | + with: |
| 104 | + service-url: ${{ secrets.KV_API_URL }} |
| 105 | + scope: pull-request |
| 106 | + key: report-comment-${{ inputs.report }} |
| 107 | + value: ${{ steps.publish.outputs.comment-id }} |
0 commit comments