1
0
forked from mirror/misskey
misskey/.github/workflows/pr-preview-deploy.yml

93 lines
3.0 KiB
YAML
Raw Normal View History

2022-06-09 01:43:35 +09:00
# Run secret-dependent integration tests only after /deploy approval
2022-06-09 00:50:23 +09:00
on:
repository_dispatch:
2022-06-09 01:43:35 +09:00
types: [deploy-command]
2022-06-09 00:50:23 +09:00
name: Deploy preview environment
jobs:
2022-06-09 01:43:35 +09:00
# Repo owner has commented /deploy on a (fork-based) pull request
2022-06-09 00:50:23 +09:00
deploy-preview-environment:
runs-on: ubuntu-latest
if:
github.event.client_payload.slash_command.sha != '' &&
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
steps:
2023-01-15 16:14:06 +09:00
- uses: actions/github-script@v6.3.3
id: check-id
env:
number: ${{ github.event.client_payload.pull_request.number }}
job: ${{ github.job }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
result-encoding: string
script: |
const { data: pull } = await github.rest.pulls.get({
...context.repo,
pull_number: process.env.number
});
const ref = pull.head.sha;
const { data: checks } = await github.rest.checks.listForRef({
...context.repo,
ref
});
const check = checks.check_runs.filter(c => c.name === process.env.job);
return check[0].id;
2023-01-15 16:14:06 +09:00
- uses: actions/github-script@v6.3.3
env:
check_id: ${{ steps.check-id.outputs.result }}
details_url: ${{ github.server_url }}/${{ github.repository }}/runs/${{ github.run_id }}
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
await github.rest.checks.update({
...context.repo,
check_run_id: process.env.check_id,
status: 'in_progress',
details_url: process.env.details_url
});
2022-06-09 00:50:23 +09:00
# Check out merge commit
2022-06-09 01:43:35 +09:00
- name: Fork based /deploy checkout
uses: actions/checkout@v4.1.1
2022-06-09 00:50:23 +09:00
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
# <insert integration tests needing secrets>
- name: Context
uses: okteto/context@latest
with:
token: ${{ secrets.OKTETO_TOKEN }}
- name: Deploy preview environment
uses: ikuradon/deploy-preview@latest
env:
2022-06-09 01:35:57 +09:00
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2022-06-09 00:50:23 +09:00
with:
2022-06-09 01:48:00 +09:00
name: pr-${{ github.event.client_payload.pull_request.number }}-syuilo
2022-06-09 00:50:23 +09:00
timeout: 15m
# Update check run called "integration-fork"
2023-01-15 16:14:06 +09:00
- uses: actions/github-script@v6.3.3
2022-06-09 00:50:23 +09:00
id: update-check-run
if: ${{ always() }}
env:
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
conclusion: ${{ job.status }}
check_id: ${{ steps.check-id.outputs.result }}
2022-06-09 00:50:23 +09:00
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { data: result } = await github.rest.checks.update({
...context.repo,
check_run_id: process.env.check_id,
2022-06-09 00:50:23 +09:00
status: 'completed',
conclusion: process.env.conclusion
});
return result;