-
Notifications
You must be signed in to change notification settings - Fork 9
Expand file tree
/
Copy pathaction.yml
More file actions
84 lines (80 loc) · 2.96 KB
/
Copy pathaction.yml
File metadata and controls
84 lines (80 loc) · 2.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
name: codex/build
description: Builds the codex documentation
inputs:
docs-builder-version:
description: The version of docs-builder to use
required: false
default: "edge"
outputs:
path-prefix:
description: The path prefix for the documentation
value: ${{ steps.generate-path-prefix.outputs.result }}
runs:
using: composite
steps:
- name: Setup docs-builder
uses: elastic/docs-actions/docs-builder/setup@v1
with:
version: ${{ inputs.docs-builder-version }}
- name: Generate env.PATH_PREFIX
id: generate-path-prefix
env:
PR_NUMBER: ${{ github.event.pull_request.number }}
GITHUB_REF_NAME: ${{ github.ref_name }}
run: | # zizmor: ignore[github-env] PATH_PREFIX from trusted workflow context
case "${GITHUB_EVENT_NAME}" in
"merge_group" | "pull_request" | "pull_request_target")
path_prefix="/_preview/${GITHUB_REPOSITORY}/pull/${PR_NUMBER}"
;;
"push" | "workflow_dispatch")
path_prefix="/_preview/${GITHUB_REPOSITORY}/tree/${GITHUB_REF_NAME}"
;;
*)
echo "Unsupported event: '${GITHUB_EVENT_NAME}'";
exit 1;
;;
esac
echo "PATH_PREFIX=${path_prefix}" >> $GITHUB_ENV
echo "result=${path_prefix}" >> $GITHUB_OUTPUT
shell: bash
- name: Generate vault role
id: generate-vault-role
shell: bash
run: |
workflow_ref=$(echo "${GITHUB_WORKFLOW_REF}" | awk -F'@' '{print $1}')
echo "${workflow_ref}"
hash=$(echo -n "${workflow_ref}" | sha256sum | awk '{print substr($1, 1, 12)}')
echo "result=token-policy-${hash}" >> "${GITHUB_OUTPUT}"
# Fetch a token for reading elastic/codex-link-index (private). Non-fatal:
# callers without codex cross-links don't need it, and callers missing the
# policy registration (catalog-info) fall back to the same anonymous-HTTPS
# behavior that existed before this step was added.
- name: Fetch ephemeral GitHub token for codex-link-index read
id: fetch-ephemeral-token
uses: elastic/ci-gh-actions/fetch-github-token@v1
continue-on-error: true
with:
vault-instance: "ci-prod"
vault-role: "${{ steps.generate-vault-role.outputs.result }}"
- name: Build
run: docs-builder --output ./.artifacts/docs/html --path-prefix ${PATH_PREFIX}
shell: bash
env:
PATH_PREFIX: ${{ env.PATH_PREFIX }}
GITHUB_TOKEN: ${{ steps.fetch-ephemeral-token.outputs.token }}
- name: Upload docs
uses: actions/upload-artifact@v7
with:
name: docs
path: .artifacts/docs/html
compression-level: 1
retention-days: 1
if-no-files-found: error
- name: Upload artifact
uses: actions/upload-artifact@v7
with:
name: links
path: .artifacts/docs/html/links.json
compression-level: 1
retention-days: 1
if-no-files-found: error