Skip to content

Commit 16b3644

Browse files
committed
Revert changes back to c7df24a
1 parent 88627fe commit 16b3644

File tree

3 files changed

+68
-95
lines changed

3 files changed

+68
-95
lines changed

.github/workflows/pr.yml

Lines changed: 1 addition & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,6 @@ on:
66
permissions:
77
contents: read
88
packages: read
9-
id-token: write
10-
pull-requests: write
11-
deployments: write
129

1310
concurrency:
1411
group: ${{ github.workflow }}-${{ github.ref }}
@@ -39,15 +36,4 @@ jobs:
3936
# we run our artifact directly please use the prebuild
4037
# elastic/docs-builder@main GitHub Action for all other repositories!
4138
- name: Build documentation
42-
env:
43-
PR_NUMBER: ${{ github.event.pull_request.number }}
44-
run: .artifacts/publish/docs-builder/release/docs-builder --strict --path-prefix "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"
45-
46-
- uses: actions/upload-artifact@v4
47-
with:
48-
name: html
49-
path: .artifacts/docs/html/
50-
51-
preview:
52-
needs: build
53-
uses: ./.github/workflows/preview.yml
39+
run: .artifacts/publish/docs-builder/release/docs-builder --strict

.github/workflows/preview-cleanup.yml

Lines changed: 0 additions & 30 deletions
This file was deleted.

.github/workflows/preview.yml

Lines changed: 67 additions & 50 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
name: preview
22

33
on:
4-
workflow_call: ~
4+
pull_request: ~
55

66
permissions:
77
contents: read
@@ -10,41 +10,55 @@ permissions:
1010
pull-requests: write
1111
deployments: write
1212

13+
env:
14+
NUGET_PACKAGES: ${{ github.workspace }}/.nuget/packages
15+
1316
jobs:
14-
deploy:
17+
build:
1518
runs-on: ubuntu-latest
1619
steps:
1720

1821
- name: Create Deployment
22+
uses: actions/github-script@v7
1923
id: deployment
20-
env:
21-
GH_TOKEN: ${{ github.token }}
22-
run: |
23-
deployment_id=$(gh api "/repos/${{ github.repository }}/deployments" \
24-
-X POST \
25-
-H 'Accept: application/vnd.github+json' \
26-
-H 'X-GitHub-Api-Version: 2022-11-28' \
27-
-f 'ref=${{ github.event.pull_request.head.ref }}' \
28-
-f 'environment=preview-${{ github.event.pull_request.number }}' \
29-
-f 'description=Preview deployment for PR ${{ github.event.pull_request.number }}' \
30-
-f auto_merge=false \
31-
-f required_contexts=[] \
32-
--jq '.id')
24+
with:
25+
result-encoding: string
26+
script: |
27+
const response = await github.rest.repos.createDeployment({
28+
issue_number: context.issue.number,
29+
owner: context.repo.owner,
30+
repo: context.repo.repo,
31+
ref: "${{ github.event.pull_request.head.ref }}",
32+
environment: `preview-${context.issue.number}`,
33+
description: `Preview deployment for PR ${context.issue.number}`,
34+
auto_merge: false,
35+
required_contexts: [],
36+
})
3337
34-
gh api "/repos/${{ github.repository }}/deployments/$deployment_id/statuses" \
35-
-X POST \
36-
-H 'Accept: application/vnd.github+json' \
37-
-H 'X-GitHub-Api-Version: 2022-11-28' \
38-
-f 'state=in_progress' \
39-
-f 'description=Deployment created' \
40-
-f 'log_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}'
38+
await github.rest.repos.createDeploymentStatus({
39+
deployment_id: response.data.id,
40+
owner: context.repo.owner,
41+
repo: context.repo.repo,
42+
state: "in_progress",
43+
description: "Deployment created",
44+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
45+
})
4146
42-
echo "id=$deployment_id" >> $GITHUB_OUTPUT
47+
return response.data.id
4348
44-
- uses: actions/download-artifact@v4
45-
with:
46-
name: html
49+
- uses: actions/checkout@v4
4750

51+
- name: Bootstrap Action Workspace
52+
id: bootstrap
53+
uses: ./.github/actions/bootstrap
54+
55+
- name: Publish AOT
56+
run: ./build.sh publishbinaries
57+
58+
- name: Build documentation
59+
env:
60+
PR_NUMBER: ${{ github.event.pull_request.number }}
61+
run: .artifacts/publish/docs-builder/release/docs-builder --strict --path-prefix "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"
4862
- name: Generate ARNs
4963
id: generate_arns
5064
shell: python
@@ -73,32 +87,35 @@ jobs:
7387
env:
7488
PR_NUMBER: ${{ github.event.pull_request.number }}
7589
run: |
76-
aws s3 sync . "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --delete
90+
aws s3 sync .artifacts/docs/html "s3://elastic-docs-v3-website-preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}" --delete
7791
aws cloudfront create-invalidation --distribution-id EKT7LT5PM8RKS --paths "/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}/*"
7892
93+
7994
- name: Update deployment status
80-
if: steps.deployment.outputs.id
81-
env:
82-
GH_TOKEN: ${{ github.token }}
83-
run: |
84-
gh api "/repos/${{ github.repository }}/deployments/${{ steps.deployment.outputs.id }}/statuses" \
85-
-X POST \
86-
-H 'Accept: application/vnd.github+json' \
87-
-H 'X-GitHub-Api-Version: 2022-11-28' \
88-
-f 'state=success' \
89-
-f 'description=Deployment completed' \
90-
-f 'environment_url=https://d2euvt1bxklciq.cloudfront.net/${{ github.repository }}/pull/${{ github.event.pull_request.number}}' \
91-
-f 'log_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}'
95+
uses: actions/github-script@v7
96+
if: steps.deployment.outputs.result
97+
with:
98+
script: |
99+
await github.rest.repos.createDeploymentStatus({
100+
owner: context.repo.owner,
101+
repo: context.repo.repo,
102+
deployment_id: ${{ steps.deployment.outputs.result }},
103+
state: "success",
104+
description: "Deployment completed",
105+
environment_url: `https://d2euvt1bxklciq.cloudfront.net/${{ github.repository }}/pull/${{ github.event.pull_request.number}}`,
106+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
107+
})
92108
93109
- name: Update Deployment Status on Failure
94-
if: failure() && steps.deployment.outputs.id
95-
env:
96-
GH_TOKEN: ${{ github.token }}
97-
run: |
98-
gh api "/repos/${{ github.repository }}/deployments/${{ steps.deployment.outputs.id }}/statuses" \
99-
-X POST \
100-
-H 'Accept: application/vnd.github+json' \
101-
-H 'X-GitHub-Api-Version: 2022-11-28' \
102-
-f 'state=failure' \
103-
-f 'description=Deployment failed' \
104-
-f 'log_url=https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}?pr=${{ github.event.pull_request.number }}'
110+
if: failure() && steps.deployment.outputs.result
111+
uses: actions/github-script@v7
112+
with:
113+
script: |
114+
await github.rest.repos.createDeploymentStatus({
115+
owner: context.repo.owner,
116+
repo: context.repo.repo,
117+
deployment_id: ${{ steps.deployment.outputs.result }},
118+
state: "failure",
119+
description: "Deployment failed",
120+
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}?pr=${context.issue.number}`,
121+
})

0 commit comments

Comments
 (0)