|
| 1 | +name: Check embedded root |
| 2 | + |
| 3 | +on: |
| 4 | + workflow_dispatch: |
| 5 | + schedule: |
| 6 | + - cron: '13 13 * * 3' |
| 7 | + |
| 8 | +jobs: |
| 9 | + check-embedded-root: |
| 10 | + runs-on: ubuntu-latest |
| 11 | + permissions: |
| 12 | + issues: write |
| 13 | + |
| 14 | + steps: |
| 15 | + - uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2 |
| 16 | + with: |
| 17 | + persist-credentials: false |
| 18 | + |
| 19 | + - uses: actions/setup-python@42375524e23c412d93fb67b49958b491fce71c38 # v5.4.0 |
| 20 | + with: |
| 21 | + python-version: "3.x" |
| 22 | + cache: "pip" |
| 23 | + cache-dependency-path: pyproject.toml |
| 24 | + |
| 25 | + - name: Setup environment |
| 26 | + run: make dev |
| 27 | + |
| 28 | + - name: Check if embedded root is up-to-date |
| 29 | + run: | |
| 30 | + make update-embedded-root |
| 31 | + git diff --exit-code |
| 32 | +
|
| 33 | +
|
| 34 | + - if: failure() |
| 35 | + name: Create an issue if embedded root is not up-to-date |
| 36 | + uses: actions/github-script@60a0d83039c74a4aee543508d2ffcb1c3799cdea # v7.0.1 |
| 37 | + with: |
| 38 | + script: | |
| 39 | + const repo = context.repo.owner + "/" + context.repo.repo |
| 40 | + const body = ` |
| 41 | + The Sigstore [TUF repository](https://tuf-repo-cdn.sigstore.dev/) contents have changed: the data embedded |
| 42 | + in sigstore-python sources can be updated. This is not urgent but will improve cold-cache performance. |
| 43 | + |
| 44 | + Run \`make update-embedded-root\` to update the embedded data. |
| 45 | + |
| 46 | + This issue was filed by _${context.workflow}_ [workflow run](${context.serverUrl}/${repo}/actions/runs/${context.runId}). |
| 47 | + ` |
| 48 | +
|
| 49 | + const issues = await github.rest.search.issuesAndPullRequests({ |
| 50 | + q: "label:embedded-root-update+state:open+type:issue+repo:" + repo, |
| 51 | + }) |
| 52 | + if (issues.data.total_count > 0) { |
| 53 | + console.log("Issue for embedded root update exists already.") |
| 54 | + } else { |
| 55 | + github.rest.issues.create({ |
| 56 | + owner: context.repo.owner, |
| 57 | + repo: context.repo.repo, |
| 58 | + title: "Embedded TUF root is not up-to-date", |
| 59 | + labels: ["embedded-root-update"], |
| 60 | + body: body, |
| 61 | + }) |
| 62 | + console.log("New issue created.") |
| 63 | + } |
0 commit comments