Repository navigation
97 lines (86 loc) · 3.52 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
97 lines (86 loc) · 3.52 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
85
86
87
88
89
90
91
92
93
94
95
96
97
name: Deploy Docs 🚀
on:
push:
branches:
- main
permissions:
contents: write
concurrency:
group: docs-deploy
cancel-in-progress: true
jobs:
Deploy:
runs-on: ubuntu-latest
permissions:
contents: write # Minimum requirement for peaceiris/actions-gh-pages
steps:
- name: Checkout
uses: actions/checkout@v4
with:
token: ${{ secrets.GITHUB_TOKEN }}
- name: Read marketing version
id: version
run: |
# 1. Read the version and trim whitespace
VER=$(tr -d '[:space:]' < version.txt)
# 2. Strict Validation: Allow only alphanumeric and dots, like 1, 1.0, or 1.2.3
# This regex rejects any string containing "/" or ".."
if [[ ! "$VER" =~ ^[0-9]+(\.[0-9]+)*$ ]]; then
echo "::error::Invalid version string found in version.txt: $VER"
exit 1
fi
echo "MARKETING_VERSION=$VER" >> "$GITHUB_ENV"
- name: Stage docs into a single publish dir
run: |
set -euxo pipefail
STAGE=".stage-docs"
rm -rf "$STAGE"
mkdir -p "$STAGE/${MARKETING_VERSION}/AdyenApplePayProvisioning"
mkdir -p "$STAGE/${MARKETING_VERSION}/AdyenApplePayExtensionProvisioning"
mkdir -p "$STAGE/${MARKETING_VERSION}/Api"
cp -R ./AdyenApplePayProvisioning/Documentation/html/* \
"$STAGE/${MARKETING_VERSION}/AdyenApplePayProvisioning/"
cp -R ./AdyenApplePayExtensionProvisioning/Documentation/html/* \
"$STAGE/${MARKETING_VERSION}/AdyenApplePayExtensionProvisioning/"
cp -R ./ApiDocumentation/* \
"$STAGE/${MARKETING_VERSION}/Api/"
# Create root index.html with links to all sections (always points to latest version)
cat > "$STAGE/index.html" <<EOF
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<title>Documentation – ${MARKETING_VERSION}</title>
<style>
body { font-family: system-ui, sans-serif; max-width: 600px; margin: 3rem auto; line-height: 1.6; }
h1 { font-size: 1.8rem; }
ul { list-style: none; padding: 0; }
li { margin: 0.5rem 0; }
a { text-decoration: none; color: #0366d6; }
a:hover { text-decoration: underline; }
</style>
</head>
<body>
<h1>Documentation (${MARKETING_VERSION})</h1>
<ul>
<li><a href="./${MARKETING_VERSION}/AdyenApplePayProvisioning/documentation/adyenapplepayprovisioning">Adyen Apple Pay Provisioning</a></li>
<li><a href="./${MARKETING_VERSION}/AdyenApplePayExtensionProvisioning/documentation/adyenapplepayextensionprovisioning">Adyen Apple Pay Extension Provisioning</a></li>
<li><a href="./${MARKETING_VERSION}/Api/">API Documentation</a></li>
</ul>
</body>
</html>
EOF
- name: Deploy to gh-pages
uses: peaceiris/actions-gh-pages@v4
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_branch: gh-pages
publish_dir: ./.stage-docs
keep_files: true
force_orphan: false
enable_jekyll: true # don’t create .nojekyll
commit_message: |
docs: publish ${MARKETING_VERSION}
- AdyenApplePayProvisioning
- AdyenApplePayExtensionProvisioning
- API