It's the time of decade for a poll PR #2339
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Preview | |
| on: | |
| workflow_run: | |
| workflows: ['Build server', 'Build assets'] | |
| types: [completed] | |
| pull_request: | |
| types: [labeled, synchronize, reopened] | |
| workflow_dispatch: | |
| jobs: | |
| gate: | |
| runs-on: ubuntu-latest | |
| if: | | |
| github.event_name == 'workflow_dispatch' || | |
| ( | |
| github.event_name == 'workflow_run' && | |
| github.event.workflow_run.conclusion == 'success' && | |
| github.event.workflow_run.head_branch == github.event.repository.default_branch | |
| ) || | |
| ( | |
| github.event_name == 'pull_request' && | |
| contains(github.event.pull_request.labels.*.name, 'preview') | |
| ) | |
| steps: | |
| - run: | | |
| echo "Building preview" | |
| echo "Triggered by: ${{ github.event_name }}" | |
| build-server: | |
| needs: [gate] | |
| if: needs.gate.result == 'success' && github.event_name != 'workflow_run' | |
| uses: ./.github/workflows/server.yml | |
| build-assets: | |
| needs: [gate] | |
| if: needs.gate.result == 'success' && github.event_name != 'workflow_run' | |
| uses: ./.github/workflows/assets.yml | |
| params: | |
| needs: [gate] | |
| if: needs.gate.result == 'success' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| tags: ${{ steps.params.outputs.tags }} | |
| deploy: ${{ steps.params.outputs.deploy }} | |
| ref: ${{ steps.params.outputs.ref }} | |
| steps: | |
| - name: Work out tags, deploy flag, and ref | |
| id: params | |
| uses: actions/github-script@3a2844b7e9c422d3c10d287c895573f7108da1b3 # v9.0.0 | |
| with: | |
| script: | | |
| // Docker tags may only contain [a-zA-Z0-9_.-] | |
| const sanitizeTag = (value) => value.replace(/[^a-zA-Z0-9_.-]/g, '-'); | |
| if (context.eventName === 'pull_request') { | |
| core.setOutput('tags', `type=raw,value=pr-${context.payload.pull_request.number}`); | |
| core.setOutput('deploy', 'false'); | |
| core.setOutput('ref', context.payload.pull_request.head.sha); | |
| return; | |
| } | |
| // push (via workflow_run) or workflow_dispatch | |
| const isWorkflowRun = context.eventName === 'workflow_run'; | |
| const branch = isWorkflowRun | |
| ? context.payload.workflow_run.head_branch | |
| : context.ref.replace('refs/heads/', ''); | |
| const sha = isWorkflowRun ? context.payload.workflow_run.head_sha : context.sha; | |
| const isDefaultBranch = branch === context.payload.repository.default_branch; | |
| const tags = [`type=raw,value=${sanitizeTag(branch)}`]; | |
| if (isDefaultBranch) tags.push('type=raw,value=latest'); | |
| core.setOutput('tags', tags.join('\n')); | |
| core.setOutput('deploy', isDefaultBranch ? 'true' : 'false'); | |
| core.setOutput('ref', sha); | |
| publish-server: | |
| needs: [gate, build-server, params] | |
| if: | | |
| always() && | |
| needs.gate.result == 'success' && | |
| ( | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Build server') || | |
| (github.event_name != 'workflow_run' && needs.build-server.result == 'success') | |
| ) | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: docker-publish-server-${{ github.event.pull_request.number || needs.params.outputs.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: ${{ needs.params.outputs.ref }} | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: lila-server | |
| run-id: ${{ github.event.workflow_run.id || github.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract artifact | |
| run: | | |
| mkdir -p lila | |
| tar --zstd -xvf *.tar.zst -C lila | |
| - name: Copy conf | |
| run: cp -r conf lila | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ghcr.io/${{ github.repository }}-server | |
| tags: ${{ needs.params.outputs.tags }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | |
| with: | |
| context: . | |
| file: .github/workflows/docker/lila.Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| publish-assets: | |
| needs: [gate, build-assets, params] | |
| if: | | |
| always() && | |
| needs.gate.result == 'success' && | |
| ( | |
| (github.event_name == 'workflow_run' && github.event.workflow_run.name == 'Build assets') || | |
| (github.event_name != 'workflow_run' && needs.build-assets.result == 'success') | |
| ) | |
| runs-on: ubuntu-latest | |
| concurrency: | |
| group: docker-publish-assets-${{ github.event.pull_request.number || needs.params.outputs.ref }} | |
| cancel-in-progress: true | |
| permissions: | |
| contents: read | |
| packages: write | |
| actions: read | |
| steps: | |
| - uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1 | |
| with: | |
| ref: ${{ needs.params.outputs.ref }} | |
| - uses: actions/download-artifact@3e5f45b2cfb9172054b4087a40e8e0b5a5461e7c # v8.0.1 | |
| with: | |
| name: lila-assets | |
| run-id: ${{ github.event.workflow_run.id || github.run_id }} | |
| github-token: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract assets | |
| run: | | |
| mkdir -p assets | |
| tar --zstd -xvf assets.tar.zst -C assets | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@37fe631027851001ddb9b187196cc803df7f5f0e # v4.3.0 | |
| - name: Log in to GitHub Container Registry | |
| uses: docker/login-action@dbcb813823bdd20940b903addbd779551569679f # v4.6.0 | |
| with: | |
| registry: ghcr.io | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| - name: Extract metadata for Docker | |
| id: meta | |
| uses: docker/metadata-action@dc802804100637a589fabce1cb79ff13a1411302 # v6.2.0 | |
| with: | |
| images: ghcr.io/${{ github.repository }}-assets | |
| tags: ${{ needs.params.outputs.tags }} | |
| - name: Build and push Docker image | |
| uses: docker/build-push-action@53b7df96c91f9c12dcc8a07bcb9ccacbed38856a # v7.3.0 | |
| with: | |
| context: . | |
| file: .github/workflows/docker/assets.Dockerfile | |
| push: true | |
| tags: ${{ steps.meta.outputs.tags }} | |
| labels: ${{ steps.meta.outputs.labels }} | |
| deploy-server: | |
| name: deploy preview (server) | |
| if: | | |
| always() && | |
| github.repository_owner == 'lichess-org' && | |
| needs.params.outputs.deploy == 'true' && | |
| needs.publish-server.result == 'success' | |
| needs: [params, publish-server] | |
| uses: lichess-org/.github/.github/workflows/deploy.yml@main | |
| secrets: | |
| deploy_webhook_url: ${{ secrets.DEPLOY_PREVIEW_SERVER_URL }} | |
| deploy-assets: | |
| name: deploy preview (assets) | |
| if: | | |
| always() && | |
| github.repository_owner == 'lichess-org' && | |
| needs.params.outputs.deploy == 'true' && | |
| needs.publish-assets.result == 'success' | |
| needs: [params, publish-assets] | |
| uses: lichess-org/.github/.github/workflows/deploy.yml@main | |
| secrets: | |
| deploy_webhook_url: ${{ secrets.DEPLOY_PREVIEW_ASSETS_URL }} |