forked from thunderbird/thunderbird-android
-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (67 loc) · 2.57 KB
/
Copy pathdeploy-docs.yml
File metadata and controls
86 lines (67 loc) · 2.57 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
---
name: Deploy docs
on:
push:
branches:
- main
paths:
- 'docs/**'
workflow_dispatch:
concurrency:
group: "pages"
cancel-in-progress: false
jobs:
build-docs:
if: ${{ github.repository_owner == 'thunderbird' }}
runs-on: ubuntu-latest
environment: botmobile
steps:
- name: App token generate
uses: actions/create-github-app-token@67018539274d69449ef7c02e8e71183d1719ab42 # v2.1.4
if: ${{ vars.BOT_CLIENT_ID }}
id: app-token
with:
app-id: ${{ vars.BOT_CLIENT_ID }}
private-key: ${{ secrets.BOT_PRIVATE_KEY }}
- name: Checkout
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
token: ${{ steps.app-token.outputs.token || github.token }}
- name: Cargo cache
uses: actions-rust-lang/setup-rust-toolchain@1780873c7b576612439a134613cc4cc74ce5538c # v1.15.2
- name: Install mdbook and extensions
run: ./docs/install.sh
- name: Build docs
run: mdbook build docs --dest-dir=./../book/docs/latest
- name: Test docs
run: mdbook test docs
- name: Clean docs
run: |
rm -rf book/docs/latest/html/assets/draw.io
rm -f book/docs/latest/html/.gitignore
rm -f book/docs/latest/html/install.sh
# Restore mermaid.min.js, it has already been copied over to book/docs/latest
git restore .
- name: Deploy docs to gh-pages
env:
APP_SLUG: ${{ steps.app-token.outputs.app-slug || 'github-actions'}}
APP_USER_ID: ${{ vars.BOT_USER_ID || '41898282' }}
run: |
git config --global user.name "${APP_SLUG}"
git config --global user.email "${APP_USER_ID}+${APP_SLUG}[bot]@users.noreply.github.com"
# Fetch the gh-pages branch
git fetch origin gh-pages || git checkout --orphan gh-pages
git checkout gh-pages
# Get the short commit hash
COMMIT_HASH=$(git rev-parse --short "$GITHUB_SHA")
# Keep necessary files and clean `docs/latest/`
mkdir -p docs/latest # Ensure the folder exists
find docs/latest -mindepth 1 -delete # Delete old files inside docs/latest
# Copy new docs to gh-pages branch
cp -r book/docs/latest/html/* docs/latest/
# Remove
rm -rf book
# Add, commit, and push changes
git add .
git commit -m "Deploy docs update from [${COMMIT_HASH}]" || echo "No changes to commit"
git push --force-with-lease origin gh-pages