2022-06-08 08:50:23 -07:00
|
|
|
# file: .github/workflows/preview-closed.yaml
|
|
|
|
on:
|
|
|
|
pull_request:
|
|
|
|
types:
|
|
|
|
- closed
|
|
|
|
|
|
|
|
name: Destroy preview environment
|
|
|
|
|
|
|
|
jobs:
|
|
|
|
destroy-preview-environment:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
2023-09-24 08:28:35 -07:00
|
|
|
- uses: actions/github-script@v6.4.1
|
2023-02-24 01:51:31 -08:00
|
|
|
id: check-conclusion
|
|
|
|
env:
|
|
|
|
number: ${{ github.event.number }}
|
|
|
|
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 === 'deploy-preview-environment');
|
|
|
|
|
|
|
|
if (check.length === 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
const { data: result } = await github.rest.checks.get({
|
|
|
|
...context.repo,
|
|
|
|
check_run_id: check[0].id,
|
|
|
|
});
|
|
|
|
|
|
|
|
return result.conclusion;
|
2022-06-08 08:50:23 -07:00
|
|
|
- name: Context
|
2023-02-24 01:51:31 -08:00
|
|
|
if: steps.check-conclusion.outputs.result == 'success'
|
2022-06-08 08:50:23 -07:00
|
|
|
uses: okteto/context@latest
|
|
|
|
with:
|
|
|
|
token: ${{ secrets.OKTETO_TOKEN }}
|
|
|
|
|
|
|
|
- name: Destroy preview environment
|
2023-02-24 01:51:31 -08:00
|
|
|
if: steps.check-conclusion.outputs.result == 'success'
|
2022-06-08 08:50:23 -07:00
|
|
|
uses: okteto/destroy-preview@latest
|
|
|
|
with:
|
2022-06-08 09:48:00 -07:00
|
|
|
name: pr-${{ github.event.number }}-syuilo
|