Skip to content

Commit 1db64d0

Browse files
committed
Various optimizations
1 parent 9322e16 commit 1db64d0

File tree

2 files changed

+34
-11
lines changed

2 files changed

+34
-11
lines changed

.github/workflows/preview-build.yml

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,24 @@ jobs:
2424
- name: Checkout
2525
uses: actions/checkout@v4
2626

27+
- name: Store PR data
28+
env:
29+
PR_NUMBER: ${{ github.event.pull_request.number }}
30+
PR_REF: ${{ github.event.pull_request.head.sha }}
31+
run: |
32+
cat << EOF > pull_request.json
33+
{
34+
"number": ${PR_NUMBER},
35+
"ref": "${PR_REF}"
36+
}
37+
EOF
38+
39+
- name: Upload PR data
40+
uses: actions/upload-artifact@v4
41+
with:
42+
name: pull-request-data
43+
path: pull_request.json
44+
2745
- name: Bootstrap Action Workspace
2846
if: github.repository == 'elastic/docs-builder'
2947
uses: ./.github/actions/bootstrap
@@ -44,13 +62,6 @@ jobs:
4462
with:
4563
prefix: "/${{ github.repository }}/pull/${{ github.event.pull_request.number }}"
4664
strict: true
47-
- name: Add pull request number to build
48-
env:
49-
PR_NUMBER: ${{ github.event.pull_request.number }}
50-
PR_REF: ${{ github.event.pull_request.head.sha }}
51-
run: |
52-
echo "${PR_NUMBER}" >> .artifacts/docs/html/pull_request_number.txt
53-
echo "${PR_REF}" >> .artifacts/docs/html/pull_request_ref.txt
5465
- uses: actions/upload-artifact@v4
5566
with:
5667
name: docs

.github/workflows/preview-deploy.yml

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -17,16 +17,20 @@ jobs:
1717
docs-deploy:
1818
runs-on: ubuntu-latest
1919
steps:
20-
- name: Download docs
20+
- name: Download PR data
2121
env:
2222
GH_TOKEN: ${{ github.token }}
2323
run: |
24-
gh run download ${{ github.event.workflow_run.id }} --name docs --repo "${GITHUB_REPOSITORY}"
24+
gh run download ${{ github.event.workflow_run.id }} \
25+
--repo "${GITHUB_REPOSITORY}" \
26+
--name pull-request-data
2527
- name: Get PR data
2628
id: pull_request
2729
run: |
28-
echo "number=$(cat pull_request_number.txt)" >> "${GITHUB_OUTPUT}"
29-
echo "ref=$(cat pull_request_ref.txt)" >> "${GITHUB_OUTPUT}"
30+
{
31+
echo "number=$(jq '.number 'pull_request.json)"
32+
echo "ref=$(jq '.number 'pull_request.json)"
33+
} >> "${GITHUB_OUTPUT}"
3034
3135
- name: Create Deployment
3236
uses: actions/github-script@v7
@@ -54,6 +58,14 @@ jobs:
5458
log_url: `https://github.com/${context.repo.owner}/${context.repo.repo}/actions/runs/${context.runId}`,
5559
})
5660
return deployment.data.id
61+
62+
- name: Download docs
63+
env:
64+
GH_TOKEN: ${{ github.token }}
65+
run: |
66+
gh run download ${{ github.event.workflow_run.id }} \
67+
--repo "${GITHUB_REPOSITORY}" \
68+
--name docs
5769
5870
- uses: elastic/docs-builder/.github/actions/aws-auth@main
5971

0 commit comments

Comments
 (0)