diff options
| author | Takuya Yoshida <hawaiianphoto@geekhost.net> | 2022-06-09 00:50:23 +0900 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2022-06-09 00:50:23 +0900 |
| commit | 327c62337e3bc63616153bbe5512ff235be9fc7e (patch) | |
| tree | 69a87e03238e9974828ca316195ebc29c966814d /.github/workflows/pr-preview-deploy.yml | |
| parent | Update CONTRIBUTING.md (diff) | |
| download | sharkey-327c62337e3bc63616153bbe5512ff235be9fc7e.tar.gz sharkey-327c62337e3bc63616153bbe5512ff235be9fc7e.tar.bz2 sharkey-327c62337e3bc63616153bbe5512ff235be9fc7e.zip | |
ok-to-test with okteto (#8799)
Diffstat (limited to '.github/workflows/pr-preview-deploy.yml')
| -rw-r--r-- | .github/workflows/pr-preview-deploy.yml | 70 |
1 files changed, 70 insertions, 0 deletions
diff --git a/.github/workflows/pr-preview-deploy.yml b/.github/workflows/pr-preview-deploy.yml new file mode 100644 index 0000000000..5890065764 --- /dev/null +++ b/.github/workflows/pr-preview-deploy.yml @@ -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; |