8
8
build :
9
9
runs-on : " ubuntu-latest"
10
10
steps :
11
+ # The git reference for the workflow isn't acessible directly. That's a workaround:
12
+ # https://github.com/actions/toolkit/issues/1264#issuecomment-2496121368
13
+ - name : " Get called workflow reference"
14
+ run : |
15
+ JWT=$(curl -s -H "Authorization: bearer $ACTIONS_ID_TOKEN_REQUEST_TOKEN" "$ACTIONS_ID_TOKEN_REQUEST_URL")
16
+ PAYLOAD=$(echo "$JWT" | cut -d '.' -f 2 | base64 -d 2>/dev/null || true)
17
+
18
+ WORKFLOW_FULL_REF=$(
19
+ echo "$PAYLOAD" \
20
+ | grep -o '"job_workflow_ref":"[^"]*"' \
21
+ | cut -d':' -f2 \
22
+ | cut -d'@' -f2 \
23
+ | tr -d '"'
24
+ )
25
+
26
+ echo "WORKFLOW_FULL_REF=$WORKFLOW_FULL_REF"
27
+
28
+ case $WORKFLOW_FULL_REF in
29
+ refs/heads/*)
30
+ WORKFLOW_REF=${WORKFLOW_FULL_REF#refs/heads/}
31
+ ;;
32
+ refs/tags/*)
33
+ WORKFLOW_REF=${WORKFLOW_FULL_REF#refs/tags/}
34
+ ;;
35
+ refs/pull/*/merge)
36
+ # exception: we got triggered by a pull request, the ref is the base branch
37
+ WORKFLOW_REF=$GITHUB_HEAD_REF
38
+ ;;
39
+ esac
40
+
41
+ echo "::notice ::WORKFLOW_FULL_REF=$WORKFLOW_FULL_REF"
42
+ echo "::notice ::WORKFLOW_REF=$WORKFLOW_REF"
43
+
44
+ echo "WORKFLOW_REF=$WORKFLOW_REF" | tee -a $GITHUB_ENV
45
+
46
+ - name : " Checkout pulp-docs repository"
47
+ uses : " actions/checkout@v4"
48
+ with :
49
+ repository : " pulp/pulp-docs"
50
+ path : " pulp-docs"
51
+ ref : " ${{ env.WORKFLOW_REF }}"
52
+ fetch-depth : 0
53
+
54
+ - name : " Get pulp-docs commit"
55
+ working-directory : " pulp-docs"
56
+ run : |
57
+ set -e
58
+ echo "CHECKOUT_SHA=$(git rev-parse HEAD)" | tee -a $GITHUB_ENV
11
59
12
60
- name : " Instructions to run locally"
13
- shell : " bash"
14
61
run : |
15
62
cat <<EOL
16
- To run this locally, make sure:
17
- 1. You have pulp-docs and your plugin checkout in the same dir.
18
- 2. You have the latest pulp-docs availabe in your python environment
19
-
20
- Then run:
63
+ Assuming you have pulp-docs and your plugin checkout in the same dir, run:
21
64
22
65
cd pulp-docs
66
+ git checkout ${{ env.CHECKOUT_SHA }}
23
67
pulp-docs fetch --dest /tmp/pulp-docs-tmp
24
68
pulp-docs build --path pulp-docs@..:${{ github.event.repository.name }}@..:/tmp/pulp-docs-tmp
25
-
26
69
EOL
27
70
28
71
# The caller repository and context is used
32
75
with :
33
76
path : " ${{ github.event.repository.name }}"
34
77
35
- - name : " Checkout pulp-docs repository"
36
- uses : " actions/checkout@v4"
37
- with :
38
- repository : " pulp/pulp-docs"
39
- path : " pulp-docs"
40
- # ref: "rewrite-as-mkdocs-plugin"
41
- # TODO: revert. using this because pulpcore-selinux is not included in rewrite-as-mkdocs-plugin
42
- ref : " experiment-reusable-ci-workflow"
43
- fetch-depth : 0
44
-
45
78
- uses : " actions/setup-python@v5"
46
79
with :
47
80
python-version : " 3.12"
@@ -54,15 +87,15 @@ jobs:
54
87
55
88
- name : " Build Docs"
56
89
working-directory : " pulp-docs"
90
+ env :
91
+ DOCS_PATH : " pulp-docs@..:${{ github.event.repository.name }}@.."
92
+ DOCS_TMPDIR : " /tmp/pulp-docs-tmp"
57
93
run : |
58
- PATH="pulp-docs@..:${{ github.event.repository.name }}@.."
59
- TMPDIR="/tmp/pulp-docs-tmp"
60
- pulp-docs fetch --path "$PATH" --dest "$TMPDIR"
61
- pulp-docs build --path "$PATH:$TMPDIR"
94
+ pulp-docs fetch --path-exclude "$DOCS_PATH" --dest "$DOCS_TMPDIR"
95
+ pulp-docs build --path "$DOCS_PATH:$DOCS_TMPDIR"
62
96
63
97
- name : " Sanity Check"
64
98
working-directory : " pulp-docs"
65
- shell : " bash"
66
99
run : |
67
100
echo "Checking that the namespace for the component under CI exists in the built docs."
68
101
ls "site/${{ github.event.repository.name }}/docs"
0 commit comments