Skip to content

Ensure we assign record with with syntax to ensure we do not update shared instances of repository #934

Ensure we assign record with with syntax to ensure we do not update shared instances of repository

Ensure we assign record with with syntax to ensure we do not update shared instances of repository #934

Workflow file for this run

name: preview-cleanup
on:
workflow_call: ~
pull_request_target:
types: [closed]
permissions:
contents: none
deployments: write
id-token: write
jobs:
destroy:
if: github.event.repository.fork == false # Skip running the job on the fork itself (It still runs on PRs on the upstream from forks)
runs-on: ubuntu-latest
steps:
- name: Delete GitHub environment
uses: actions/github-script@v7
id: delete-deployment
with:
script: |
const { owner, repo } = context.repo;
const deployments = await github.rest.repos.listDeployments({
owner,
repo,
environment: 'docs-preview',
task: `docs-preview-${context.issue.number}`,
});
core.setOutput('is-empty', deployments.data.length === 0)
for (const deployment of deployments.data) {
await github.rest.repos.createDeploymentStatus({
owner,
repo,
deployment_id: deployment.id,
state: 'inactive',
description: 'Marking deployment as inactive'
});
await github.rest.repos.deleteDeployment({
owner,
repo,
deployment_id: deployment.id
});
}
- uses: elastic/docs-builder/.github/actions/aws-auth@main
if: steps.delete-deployment.outputs.is-empty == 'false'
- name: Delete s3 objects
if: steps.delete-deployment.outputs.is-empty == 'false'
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
run: |
aws s3 rm "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --recursive