-
Notifications
You must be signed in to change notification settings - Fork 2
116 lines (95 loc) · 4.08 KB
/
update-mdbook.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Deploy mdBook Site to Pages
on:
push:
branches:
- "*"
workflow_dispatch:
permissions:
contents: read
id-token: write
pages: write
packages: write
concurrency:
group: pages
cancel-in-progress: true
jobs:
build-docker:
runs-on: ubuntu-latest
outputs:
image_built: ${{ steps.check_image.outputs.image_built }}
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Check if Docker Image Exists
id: check_image
run: |
IMAGE="ghcr.io/${{ github.repository }}:latest"
if docker pull $IMAGE > /dev/null 2>&1; then
echo "Image exists."
echo "image_built=false" >> $GITHUB_OUTPUT
else
echo "Image does not exist."
echo "image_built=true" >> $GITHUB_OUTPUT
fi
- name: Build and Push Docker Image
if: steps.check_image.outputs.image_built == 'true'
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:latest
load: false
cache-from: type=registry,ref=ghcr.io/${{ github.repository_owner }}/mdbook:latest
cache-to: type=inline
deploy-mdbook:
needs: build-docker
runs-on: ubuntu-latest
container:
image: ghcr.io/${{ github.repository }}:latest
options: --user root
steps:
- name: Log in to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Checkout Source
uses: actions/checkout@v4
- name: Install Dependencies
run: apk add --no-cache curl
- name: Prepare Assets Directories
run: mkdir -p src/fonts src/assets
- name: Download Additional Assets
run: |
# Devicon Fonts and CSS
curl -sSf -o devicon.min.css https://raw.githubusercontent.com/devicons/devicon/master/devicon.min.css
curl -sSf -o src/fonts/devicon.eot https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.eot
curl -sSf -o src/fonts/devicon.svg https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.svg
curl -sSf -o src/fonts/devicon.ttf https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.ttf
curl -sSf -o src/fonts/devicon.woff https://raw.githubusercontent.com/devicons/devicon/master/fonts/devicon.woff
# WhichLang Assets
curl -sSf -o src/assets/whichlang.css https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/src/whichlang.css
curl -sSf -o src/assets/whichlang.js https://raw.githubusercontent.com/phoenixr-codes/mdbook-whichlang/master/dist/whichlang.js
- name: Install Catppuccin Theme
run: mdbook-catppuccin install
- name: Build the mdBook Site
run: mdbook build
- name: Turn off Jekyll
run: touch book/.nojekyll
- name: Upload Artifact
uses: actions/upload-pages-artifact@v3
with:
path: ./book
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4
if: ${{ github.ref == 'refs/heads/main' }}