|
| 1 | +# One half of the adaptation PR CI; the other half lives in `pr-release.yml`. |
| 2 | +name: Adaptation PR CI |
| 3 | + |
| 4 | +on: |
| 5 | + pull_request_target: |
| 6 | + types: [labeled] |
| 7 | + branches: [master] |
| 8 | + |
| 9 | +jobs: |
| 10 | + main: |
| 11 | + runs-on: ubuntu-slim |
| 12 | + if: github.event.label.name == 'downstream' && github.repository == 'leanprover/lean4' |
| 13 | + steps: |
| 14 | + # Determine the PR toolchain tag (see `pr-release.yml` for how it is |
| 15 | + # produced) and whether the corresponding release already exists in |
| 16 | + # `leanprover/lean4-pr-releases`. |
| 17 | + - name: Check if PR toolchain exists |
| 18 | + id: toolchain |
| 19 | + uses: actions/github-script@v9 |
| 20 | + with: |
| 21 | + script: | |
| 22 | + const number = context.payload.pull_request.number; |
| 23 | + const shortSha = context.payload.pull_request.head.sha.substring(0, 7); |
| 24 | + const tag = `pr-release-${number}-${shortSha}`; |
| 25 | + const toolchain = `leanprover/lean4-pr-releases:${tag}`; |
| 26 | +
|
| 27 | + let exists = false; |
| 28 | + try { |
| 29 | + await github.rest.repos.getReleaseByTag({ |
| 30 | + owner: 'leanprover', |
| 31 | + repo: 'lean4-pr-releases', |
| 32 | + tag, |
| 33 | + }); |
| 34 | + exists = true; |
| 35 | + } catch (e) { |
| 36 | + if (e.status !== 404) throw e; |
| 37 | + } |
| 38 | +
|
| 39 | + if (exists) core.info(`Toolchain ${toolchain} exists`); |
| 40 | + else core.info(`Toolchain ${toolchain} does not exist yet`); |
| 41 | +
|
| 42 | + core.setOutput('toolchain', toolchain); |
| 43 | + core.setOutput('exists', exists); |
| 44 | +
|
| 45 | + - name: Create GitHub App token |
| 46 | + uses: actions/create-github-app-token@v3 |
| 47 | + id: app-token |
| 48 | + with: |
| 49 | + client-id: ${{ vars.DOWNSTREAM_LEAN4_APP_CLIENT_ID }} |
| 50 | + private-key: ${{ secrets.DOWNSTREAM_LEAN4_APP_PRIVATE_KEY }} |
| 51 | + repositories: lean4,downstream-lean4 |
| 52 | + |
| 53 | + - name: Configure git |
| 54 | + uses: leanprover/downstream-lean4/.downstream/actions/configure-git@master |
| 55 | + with: |
| 56 | + name: ${{ steps.app-token.outputs.app-slug }}[bot] |
| 57 | + |
| 58 | + - name: Checkout downstream repo |
| 59 | + uses: actions/checkout@v6 |
| 60 | + with: |
| 61 | + repository: leanprover/downstream-lean4 |
| 62 | + ref: green |
| 63 | + token: ${{ steps.app-token.outputs.token }} |
| 64 | + path: downstream |
| 65 | + filter: tree:0 |
| 66 | + fetch-depth: 0 |
| 67 | + |
| 68 | + - name: Create adaptation PR |
| 69 | + uses: leanprover/downstream-lean4/.downstream/actions/adaptation-pr@master |
| 70 | + with: |
| 71 | + app-token: ${{ steps.app-token.outputs.token }} |
| 72 | + app-slug: ${{ steps.app-token.outputs.app-slug }} |
| 73 | + upstream-pr: ${{ github.event.pull_request.number }} |
| 74 | + upstream-ci-green: ${{ steps.toolchain.outputs.exists }} |
| 75 | + downstream-repo: leanprover/downstream-lean4 |
| 76 | + downstream-clone: downstream |
| 77 | + downstream-label: adaptation |
| 78 | + override-toolchain: ${{ steps.toolchain.outputs.toolchain }} |
0 commit comments