Skip to content

Commit f1cd7d0

Browse files
committed
chore(ci): remove preview-build/preview-cleanup; inline docs-preview-cleanup-local
- Delete preview-build.yml (reusable workflow removed from this repo). - Replace preview-cleanup.yml with docs-preview-cleanup-local.yml content: inline GitHub deployment + S3 cleanup via aws-auth (no docs-actions). - Drop docs-actions reusable call from docs-preview-cleanup-local. - Adjust docs-preview-local.yml header comment. Made-with: Cursor
1 parent 1860692 commit f1cd7d0

4 files changed

Lines changed: 43 additions & 664 deletions

File tree

Lines changed: 42 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
name: Docs preview cleanup (local)
22

3-
# Pairs with docs-preview-local.yml. Delegates to elastic/docs-actions instead of maintaining
4-
# duplicate cleanup logic here (docs-eng-team#474). preview-cleanup.yml remains workflow_call-only
5-
# for out-of-repo callers.
3+
# Runs when a PR is closed. Pairs with docs-preview-local.yml (push/PR build).
4+
# Inlined cleanup: GitHub deployment records + S3 preview prefix (no docs-actions call).
65

76
on:
87
pull_request_target:
@@ -15,6 +14,43 @@ permissions:
1514

1615
jobs:
1716
destroy:
18-
if: github.event.repository.fork == false
19-
uses: elastic/docs-actions/.github/workflows/docs-preview-cleanup.yml@main
20-
secrets: inherit
17+
if: github.event.repository.fork == false # Skip on fork repo; upstream PRs still run here.
18+
runs-on: ubuntu-latest
19+
steps:
20+
- name: Delete GitHub environment
21+
uses: actions/github-script@v8
22+
id: delete-deployment
23+
with:
24+
script: |
25+
const { owner, repo } = context.repo;
26+
const deployments = await github.rest.repos.listDeployments({
27+
owner,
28+
repo,
29+
environment: 'docs-preview',
30+
task: `docs-preview-${context.issue.number}`,
31+
});
32+
core.setOutput('is-empty', deployments.data.length === 0)
33+
for (const deployment of deployments.data) {
34+
await github.rest.repos.createDeploymentStatus({
35+
owner,
36+
repo,
37+
deployment_id: deployment.id,
38+
state: 'inactive',
39+
description: 'Marking deployment as inactive'
40+
});
41+
await github.rest.repos.deleteDeployment({
42+
owner,
43+
repo,
44+
deployment_id: deployment.id
45+
});
46+
}
47+
48+
- uses: elastic/docs-builder/.github/actions/aws-auth@main
49+
if: steps.delete-deployment.outputs.is-empty == 'false'
50+
51+
- name: Delete s3 objects
52+
if: steps.delete-deployment.outputs.is-empty == 'false'
53+
env:
54+
PR_NUMBER: ${{ github.event.pull_request.number }}
55+
run: |
56+
aws s3 rm "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --recursive

.github/workflows/docs-preview-local.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: Docs preview (local)
22

33
# In-repo docs build using dotnet run (elastic/docs-builder only). Replaces the former
4-
# github.repository branches in preview-build.yml; consumers still use preview-build.yml (Docker).
4+
# Previously lived in preview-build.yml (removed); this repo builds docs from source here.
55
# Triggers are only pull_request and push — conditions below match those events only.
66

77
on:

0 commit comments

Comments
 (0)