mirror of
https://github.com/misskey-dev/misskey.git
synced 2024-12-22 06:35:10 +01:00
ok-to-test with okteto (#8799)
This commit is contained in:
parent
3dba63afbb
commit
327c62337e
4 changed files with 127 additions and 0 deletions
36
.github/workflows/ok-to-test.yml
vendored
Normal file
36
.github/workflows/ok-to-test.yml
vendored
Normal file
|
@ -0,0 +1,36 @@
|
||||||
|
# If someone with write access comments "/ok-to-test" on a pull request, emit a repository_dispatch event
|
||||||
|
name: Ok To Test
|
||||||
|
|
||||||
|
on:
|
||||||
|
issue_comment:
|
||||||
|
types: [created]
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
ok-to-test:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
# Only run for PRs, not issue comments
|
||||||
|
if: ${{ github.event.issue.pull_request }}
|
||||||
|
steps:
|
||||||
|
# Generate a GitHub App installation access token from an App ID and private key
|
||||||
|
# To create a new GitHub App:
|
||||||
|
# https://developer.github.com/apps/building-github-apps/creating-a-github-app/
|
||||||
|
# See app.yml for an example app manifest
|
||||||
|
- name: Generate token
|
||||||
|
id: generate_token
|
||||||
|
uses: tibdex/github-app-token@v1
|
||||||
|
with:
|
||||||
|
app_id: ${{ secrets.APP_ID }}
|
||||||
|
private_key: ${{ secrets.PRIVATE_KEY }}
|
||||||
|
|
||||||
|
- name: Slash Command Dispatch
|
||||||
|
uses: peter-evans/slash-command-dispatch@v1
|
||||||
|
env:
|
||||||
|
TOKEN: ${{ steps.generate_token.outputs.token }}
|
||||||
|
with:
|
||||||
|
token: ${{ env.TOKEN }} # GitHub App installation access token
|
||||||
|
# token: ${{ secrets.PERSONAL_ACCESS_TOKEN }} # PAT or OAuth token will also work
|
||||||
|
reaction-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
issue-type: pull-request
|
||||||
|
commands: ok-to-test
|
||||||
|
named-args: true
|
||||||
|
permission: write
|
70
.github/workflows/pr-preview-deploy.yml
vendored
Normal file
70
.github/workflows/pr-preview-deploy.yml
vendored
Normal file
|
@ -0,0 +1,70 @@
|
||||||
|
# Run secret-dependent integration tests only after /ok-to-test approval
|
||||||
|
on:
|
||||||
|
repository_dispatch:
|
||||||
|
types: [ok-to-test-command]
|
||||||
|
|
||||||
|
name: Deploy preview environment
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
# Repo owner has commented /ok-to-test on a (fork-based) pull request
|
||||||
|
deploy-preview-environment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
if:
|
||||||
|
github.event_name == 'repository_dispatch' &&
|
||||||
|
github.event.client_payload.slash_command.sha != '' &&
|
||||||
|
contains(github.event.client_payload.pull_request.head.sha, github.event.client_payload.slash_command.sha)
|
||||||
|
steps:
|
||||||
|
|
||||||
|
# Check out merge commit
|
||||||
|
- name: Fork based /ok-to-test checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
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:
|
||||||
|
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
with:
|
||||||
|
name: pr-${{ github.event.client_payload.pull_request.number }}-misskey-dev
|
||||||
|
timeout: 15m
|
||||||
|
|
||||||
|
# Update check run called "integration-fork"
|
||||||
|
- uses: actions/github-script@v5
|
||||||
|
id: update-check-run
|
||||||
|
if: ${{ always() }}
|
||||||
|
env:
|
||||||
|
number: ${{ github.event.client_payload.pull_request.number }}
|
||||||
|
job: ${{ github.job }}
|
||||||
|
# Conveniently, job.status maps to https://developer.github.com/v3/checks/runs/#update-a-check-run
|
||||||
|
conclusion: ${{ job.status }}
|
||||||
|
with:
|
||||||
|
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
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);
|
||||||
|
|
||||||
|
const { data: result } = await github.rest.checks.update({
|
||||||
|
...context.repo,
|
||||||
|
check_run_id: check[0].id,
|
||||||
|
status: 'completed',
|
||||||
|
conclusion: process.env.conclusion
|
||||||
|
});
|
||||||
|
|
||||||
|
return result;
|
21
.github/workflows/pr-preview-destroy.yml
vendored
Normal file
21
.github/workflows/pr-preview-destroy.yml
vendored
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
# file: .github/workflows/preview-closed.yaml
|
||||||
|
on:
|
||||||
|
pull_request:
|
||||||
|
types:
|
||||||
|
- closed
|
||||||
|
|
||||||
|
name: Destroy preview environment
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
destroy-preview-environment:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Context
|
||||||
|
uses: okteto/context@latest
|
||||||
|
with:
|
||||||
|
token: ${{ secrets.OKTETO_TOKEN }}
|
||||||
|
|
||||||
|
- name: Destroy preview environment
|
||||||
|
uses: okteto/destroy-preview@latest
|
||||||
|
with:
|
||||||
|
name: pr-${{ github.event.number }}-misskey-dev
|
Loading…
Reference in a new issue