mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-17 21:25:40 +00:00
93ef759a25
When a developer attaches the "preview" label, a build is created and published on https://preview.openttd.org/. After that, new pushes to the PR are automatically build (as long as the "preview" label exists). If a non-developer attaches the "preview" label, it will be removed.
67 lines
2.3 KiB
YAML
67 lines
2.3 KiB
YAML
name: Preview label
|
|
|
|
on:
|
|
pull_request_target:
|
|
types:
|
|
- labeled
|
|
|
|
env:
|
|
TEAM_CORE_DEVELOPER: core-developers
|
|
|
|
jobs:
|
|
check_preview_label:
|
|
name: Check for preview label
|
|
if: github.event.action == 'labeled' && github.event.label.name == 'preview'
|
|
|
|
runs-on: ubuntu-20.04
|
|
|
|
steps:
|
|
- name: Check if label was added by core developer
|
|
id: core_developer
|
|
continue-on-error: true
|
|
uses: octokit/request-action@v2.x
|
|
with:
|
|
route: GET /orgs/OpenTTD/teams/${{ env.TEAM_CORE_DEVELOPER }}/memberships/${{ github.event.sender.login }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
|
|
- if: steps.core_developer.outcome == 'failure'
|
|
name: Remove preview label if not core developer
|
|
uses: octokit/request-action@v2.x
|
|
with:
|
|
route: DELETE /repos/{owner}/{repo}/issues/{issue_number}/labels/preview
|
|
owner: ${{ github.event.repository.owner.login }}
|
|
repo: ${{ github.event.repository.name }}
|
|
issue_number: ${{ github.event.number }}
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
|
|
- if: steps.core_developer.outcome == 'success'
|
|
name: Create deployment
|
|
id: deployment
|
|
uses: octokit/request-action@v2.x
|
|
with:
|
|
route: POST /repos/{owner}/{repo}/deployments
|
|
mediaType: |
|
|
previews:
|
|
- ant-man
|
|
- flash
|
|
owner: ${{ github.event.repository.owner.login }}
|
|
repo: ${{ github.event.repository.name }}
|
|
ref: ${{ github.event.pull_request.head.sha }}
|
|
task: deploy:preview
|
|
auto_merge: false
|
|
required_contexts: "[]"
|
|
environment: preview-pr-${{ github.event.number }}
|
|
description: "Preview for Pull Request #${{ github.event.number }}"
|
|
env:
|
|
GITHUB_TOKEN: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
|
|
- if: steps.core_developer.outcome == 'success'
|
|
name: Trigger 'preview build'
|
|
uses: peter-evans/repository-dispatch@v1
|
|
with:
|
|
token: ${{ secrets.PREVIEW_GITHUB_TOKEN }}
|
|
event-type: "Preview build #${{ github.event.number }}"
|
|
client-payload: '{"folder": "pr${{ github.event.number }}", "sha": "${{ github.event.pull_request.head.sha }}", "deployment_id": "${{ fromJson(steps.deployment.outputs.data).id }}"}'
|