-
Notifications
You must be signed in to change notification settings - Fork 4
81 lines (69 loc) · 2.13 KB
/
pages.yml
File metadata and controls
81 lines (69 loc) · 2.13 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
name: Pages
on:
push:
branches:
- main
paths:
- 'mkdocs.yml'
- 'docs/site/**'
- 'docs/INDEX.md'
- 'docs/introduction-ddd-guide.md'
- 'docs/common-*.md'
- 'docs/features-*.md'
- 'docs/testing-*.md'
- '.github/workflows/pages.yml'
workflow_dispatch:
permissions:
contents: write
defaults:
run:
shell: bash
jobs:
publish:
name: Build and publish landing site
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Build site
shell: pwsh
run: |
./docs/site/scripts/build-pages.ps1
- name: Verify static output
run: |
test -f .github/pages/index.html
- name: Publish to gh-pages
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
set -euo pipefail
SITE_DIR="${GITHUB_WORKSPACE}/.github/pages"
TARGET_DIR="$(mktemp -d)"
REMOTE_URL="https://x-access-token:${GITHUB_TOKEN}@github.com/${GITHUB_REPOSITORY}.git"
git config --global user.name "github-actions[bot]"
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
if git ls-remote --exit-code --heads "${REMOTE_URL}" gh-pages >/dev/null 2>&1; then
git clone --depth 1 --branch gh-pages "${REMOTE_URL}" "${TARGET_DIR}"
else
git init "${TARGET_DIR}"
(
cd "${TARGET_DIR}"
git checkout --orphan gh-pages
git remote add origin "${REMOTE_URL}"
)
fi
find "${TARGET_DIR}" -mindepth 1 -maxdepth 1 ! -name .git -exec rm -rf {} +
cp -R "${SITE_DIR}/." "${TARGET_DIR}/"
touch "${TARGET_DIR}/.nojekyll"
(
cd "${TARGET_DIR}"
git add -A
if git diff --cached --quiet; then
echo "No site changes to publish."
exit 0
fi
git commit -m "docs: publish site for ${GITHUB_SHA}"
git push origin HEAD:gh-pages --force
)