Skip to content

Commit 9ac924a

Browse files
chore: add reusable workflows validate-docs and upload-to-splunkbase (#442)
### Description Adopt validate-docs and upload-to-splunkbase reusable workflows. This change doesn't affect current workflows and will be tested on develop branch. ### Checklist - [ ] `README.md` has been updated or is not required - [ ] push trigger tests - [ ] manual release test - [ ] automated releases test - [ ] pull request trigger tests - [ ] schedule trigger tests - [ ] workflow errors/warnings reviewed and addressed ### Testing done (for each selected checkbox, the corresponding test results link should be listed here)
1 parent a3047b5 commit 9ac924a

File tree

2 files changed

+119
-0
lines changed

2 files changed

+119
-0
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
name: publish-to-splunkbase
2+
on:
3+
workflow_call:
4+
inputs:
5+
addon_version:
6+
description: 'The version of the add-on to publish to Splunkbase'
7+
required: true
8+
type: string
9+
splunk_versions:
10+
description: 'Comma-separated list of supported Splunk versions'
11+
required: true
12+
type: string
13+
cim_versions:
14+
description: 'Comma-separated list of supported CIM versions'
15+
required: true
16+
type: string
17+
secrets:
18+
SPL_COM_USERNAME:
19+
description: 'Splunk Community username'
20+
required: true
21+
SPL_COM_PASSWORD:
22+
description: 'Splunk Community password'
23+
required: true
24+
25+
jobs:
26+
inputs-validator:
27+
runs-on: ubuntu-latest
28+
steps:
29+
- id: matrix
30+
uses: splunk/[email protected]
31+
with:
32+
features: PYTHON39
33+
publish:
34+
runs-on: ubuntu-latest
35+
needs:
36+
- inputs-validator
37+
steps:
38+
- uses: actions/checkout@v4
39+
- uses: actions/setup-python@v5
40+
with:
41+
python-version: "3.12"
42+
- run: pip install splunk_add_on_ucc_framework-5.69.1-py3-none-any.whl
43+
- name: Fetch build
44+
env:
45+
GH_TOKEN: ${{ github.token }}
46+
run: |
47+
gh release download v${{ inputs.addon_version }} --pattern "*${{ inputs.addon_version }}.spl" --output release.spl
48+
- run: |
49+
APP_ID=$(cat .splunkbase)
50+
export APP_ID
51+
ucc-gen publish \
52+
--stage \
53+
--app-id "$APP_ID" \
54+
--package-path release.spl \
55+
--splunk-versions ${{ inputs.splunk_versions }} \
56+
--cim-versions ${{ inputs.cim_versions }} \
57+
--username ${{ secrets.SPL_COM_USERNAME }} \
58+
--password ${{ secrets.SPL_COM_PASSWORD }}
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: validate-deploy-docs
2+
3+
on:
4+
workflow_call:
5+
6+
jobs:
7+
validate-docs-change:
8+
runs-on: ubuntu-latest
9+
outputs:
10+
status: ${{ steps.validate.outputs.status }}
11+
steps:
12+
- uses: actions/checkout@v4
13+
- uses: actions/setup-python@v5
14+
with:
15+
python-version: 3.12
16+
- name: Install mkdocs and plugins
17+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
18+
- name: Validate docs change
19+
id: validate
20+
shell: bash
21+
run: |
22+
RED='\033[0;31m'
23+
GREEN='\033[0;32m'
24+
NC='\033[0m'
25+
if mkdocs build --strict; then
26+
echo "status=success" >> "$GITHUB_OUTPUT"
27+
echo -e "${GREEN}Docs validation success${NC}"
28+
else
29+
echo "status=failure" >> "$GITHUB_OUTPUT"
30+
echo -e "${RED}Docs validation failure${NC}"
31+
exit 1
32+
fi
33+
34+
deploy-docs:
35+
needs:
36+
- validate-docs-change
37+
runs-on: ubuntu-latest
38+
permissions:
39+
contents: write
40+
pages: write
41+
if: github.event_name == 'workflow_dispatch' && github.ref == 'refs/heads/main'
42+
steps:
43+
- uses: actions/checkout@v4
44+
- uses: actions/setup-python@v5
45+
with:
46+
python-version: 3.12
47+
- name: Install mkdocs and plugins
48+
run: pip install mkdocs==1.6.0 mkdocs-material==9.5.32 mkdocs-print-site-plugin==2.6.0
49+
- name: Build and Deploy docs
50+
id: deploy
51+
shell: bash
52+
run: |
53+
RED='\033[0;31m'
54+
GREEN='\033[0;32m'
55+
NC='\033[0m'
56+
if [ "${{ needs.validate-docs-change.outputs.status }}" == "failure" ]; then
57+
echo -e "${RED}Docs validation failed, abort docs deployment... (for more details look at Validate docs change job)${NC}"
58+
exit 1
59+
fi
60+
mkdocs gh-deploy --force
61+
echo -e "${GREEN}Deployed docs on github!${NC}"

0 commit comments

Comments
 (0)