| 1 | name: Mirror from GitHub |
| 2 | |
| 3 | # Keeps diffinery.com/codician/diffinery in step with github.com/codician-team/diffinery, |
| 4 | # where development happens, through scripts/mirror-from-github.sh: GitHub's main and tags |
| 5 | # are copied as they are, and Diffinery runs CI on each copied commit. Runs on Diffinery |
| 6 | # only. Uses DIFFINERY_MIRROR_TOKEN (a Diffinery token with the admin scope, of a person who |
| 7 | # is an admin of codician/diffinery), a secret of the github-mirror environment. That |
| 8 | # environment is limited to protected branches, so only main's runs get it. Without the |
| 9 | # token the job says so and does nothing. |
| 10 | on: |
| 11 | schedule: |
| 12 | - cron: "*/15 * * * *" |
| 13 | workflow_dispatch: |
| 14 | |
| 15 | permissions: |
| 16 | contents: read |
| 17 | |
| 18 | concurrency: |
| 19 | group: mirror-from-github |
| 20 | cancel-in-progress: false |
| 21 | |
| 22 | jobs: |
| 23 | mirror: |
| 24 | name: Copy GitHub's main to Diffinery |
| 25 | if: ${{ github.server_url != 'https://github.com' && github.repository == 'codician/diffinery' }} |
| 26 | runs-on: ${{ vars.DIFFINERY_RUNS_ON || 'ubuntu-latest' }} |
| 27 | environment: github-mirror |
| 28 | timeout-minutes: 10 |
| 29 | env: |
| 30 | DIFFINERY_TOKEN: ${{ secrets.DIFFINERY_MIRROR_TOKEN }} |
| 31 | steps: |
| 32 | - name: Check the Diffinery token |
| 33 | id: token |
| 34 | run: | |
| 35 | if [ -z "$DIFFINERY_TOKEN" ]; then |
| 36 | echo "::notice::DIFFINERY_MIRROR_TOKEN is not set, so Diffinery is not updated." |
| 37 | echo "skip=true" >> "$GITHUB_OUTPUT" |
| 38 | fi |
| 39 | - uses: actions/checkout@v4 |
| 40 | if: steps.token.outputs.skip != 'true' |
| 41 | - if: steps.token.outputs.skip != 'true' |
| 42 | run: scripts/mirror-from-github.sh |