Debian Codegraph @

.github/workflows/NotifyTracking.yml

raw
1 name: NotifyTracking
2
3 # spell-checker:ignore zizmor
4 # spell-checker:ignore (misc) busybox toybox multisize
5
6 ## Tell uutils/coreutils-tracking to refresh as soon as a workflow that
7 ## produces one of its inputs has finished on the default branch, so its graphs
8 ## follow the data rather than wait for its scheduled refresh.
9 ##
10 ## 'GnuTests' publishes 'test-summary' and 'aggregated-result'; 'make' publishes
11 ## 'busybox-result.json', 'toybox-result.json', 'size-result' and
12 ## 'individual-size-result'. The tracking workflow picks up whatever is newest
13 ## for each of them, so a notification from either is enough to run it.
14
15 on:
16 workflow_run:
17 workflows: ["GnuTests", "make"]
18 types:
19 - completed # zizmor: ignore[dangerous-triggers]
20
21 permissions: {}
22
23 jobs:
24 dispatch:
25 name: Trigger the tracking refresh
26 ## Nothing is checked out and no result is read here, so the untrusted
27 ## content a 'workflow_run' trigger can carry is never executed.
28 ##
29 ## A failed run still counts. 'GnuTests' uploads its results and only then
30 ## fails the comparison when it finds a new failure, and 'publish-reference'
31 ## publishes regardless; requiring success here would leave the graphs
32 ## un-refreshed for exactly the regressions they exist to show.
33 if: >
34 github.repository == 'uutils/coreutils'
35 && github.event.workflow_run.event == 'push'
36 && github.event.workflow_run.head_branch == github.event.repository.default_branch
37 && github.event.workflow_run.conclusion != 'cancelled'
38 && github.event.workflow_run.conclusion != 'skipped'
39 runs-on: ubuntu-latest
40 ## The 'secrets' context is not available in a step's 'if:', so fold the
41 ## check into a job-level env var, which is.
42 env:
43 HAVE_APP_CREDENTIALS: ${{ secrets.TRACKING_APP_ID != '' && secrets.TRACKING_APP_PRIVATE_KEY != '' }}
44 steps:
45 ## A GITHUB_TOKEN is scoped to the repository it runs in, so writing to a
46 ## sibling repository needs a credential of its own even within the same
47 ## organization. This uses an organization-owned GitHub App rather than a
48 ## personal access token: it is not tied to an individual account and does
49 ## not silently expire. Install it on uutils/coreutils-tracking only, with
50 ## 'contents: write', which is what the repository_dispatch endpoint needs.
51 - name: Mint a token for the tracking repository
52 id: app-token
53 if: env.HAVE_APP_CREDENTIALS == 'true'
54 uses: actions/create-github-app-token@v3
55 with:
56 app-id: ${{ secrets.TRACKING_APP_ID }}
57 private-key: ${{ secrets.TRACKING_APP_PRIVATE_KEY }}
58 owner: uutils
59 repositories: coreutils-tracking
60
61 - name: Send the repository_dispatch
62 shell: bash
63 env:
64 GH_TOKEN: ${{ steps.app-token.outputs.token }}
65 SOURCE_WORKFLOW: ${{ github.event.workflow_run.name }}
66 SOURCE_RUN_ID: ${{ github.event.workflow_run.id }}
67 SOURCE_SHA: ${{ github.event.workflow_run.head_sha }}
68 run: |
69 ## Send the repository_dispatch
70 ## A missing token is not an error: the tracking repository still
71 ## refreshes on its own schedule, this only makes it prompt.
72 if [[ -z "${GH_TOKEN}" ]]; then
73 echo "::warning ::TRACKING_APP_ID / TRACKING_APP_PRIVATE_KEY are not set; leaving the tracking repository to its scheduled refresh."
74 exit 0
75 fi
76 gh api --method POST 'repos/uutils/coreutils-tracking/dispatches' \
77 -f 'event_type=refresh-data' \
78 -f "client_payload[workflow]=${SOURCE_WORKFLOW}" \
79 -f "client_payload[run_id]=${SOURCE_RUN_ID}" \
80 -f "client_payload[sha]=${SOURCE_SHA}"
81 echo "::notice ::Asked uutils/coreutils-tracking to refresh after '${SOURCE_WORKFLOW}' (${SOURCE_SHA})."