-
Notifications
You must be signed in to change notification settings - Fork 139
99 lines (93 loc) · 2.98 KB
/
docs.yml
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
98
99
# VitePress Builder
#
# ---
#
# This action relies on two environment variables:
# - GIT_COMMITTER_NAME (see: `commit` job)
# - GIT_COMMITTER_EMAIL (see: `commit` job)
#
# Configure these in the repo by visiting Settings > Actions > Variables!
#
# In addition, it expects that an `ORG_ACCESS_TOKEN` secret is available, to clone from (and push to) the `pixelandtonic/docs.craftcms.com` repository. This is handled by a second `actions/checkout` step.
name: Build VitePress Documentation
on:
push:
branches:
# We don’t have a good way to parameterize this into friendly URLs, so it's maintained per-branch:
- 4.x
workflow_dispatch:
concurrency:
# When a new job is pushed, clear cancel pending ones for the same branch:
group: docs-build-${{ github.ref_name }}
cancel-in-progress: true
jobs:
# Build job
build:
name: Build VitePress Site
runs-on: ubuntu-latest
outputs:
short_hash: ${{ steps.hash.outputs.short_hash }}
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20
cache: npm
- name: Install dependencies
run: npm ci
- name: Build with VitePress
run: npm run docs:build
- name: Save bundle
uses: actions/upload-artifact@v4
with:
name: vitepress-output
path: docs/.vitepress/dist
retention-days: 1 # Only useful for the duration of this workflow!
- name: Record hash
id: hash
run: echo "short_hash=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
commit:
name: Commit artifacts
needs: build
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
with:
repository: pixelandtonic/docs.craftcms.com
token: ${{ secrets.ORG_ACCESS_TOKEN }}
path: docs.craftcms.com
- name: Download VitePress Output
uses: actions/download-artifact@v4
with:
name: vitepress-output
path: build
- name: Clear files
run: rm -rf docs.craftcms.com/docs/feed-me/v4
- name: Move artifacts
run: mv build docs.craftcms.com/docs/feed-me/v4
- name: Commit changes
working-directory: docs.craftcms.com
run: |
git config user.name "${{ vars.GIT_COMMITTER_NAME }}"
git config user.email "${{ vars.GIT_COMMITTER_EMAIL }}"
git add --all
git commit -a -m "VitePress build: Feed Me 4.x (${{ needs.build.outputs.short_hash }})"
git push
notify:
name: Send Slack notification
runs-on: ubuntu-latest
needs: commit
steps:
- name: Trigger webhook
uses: slackapi/slack-github-action@v1.25.0
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
with:
payload: |
{
"product": "Feed Me ${{ github.ref_name }}",
"url": "https://docs.craftcms.com/feed-me/v4"
}