-
Notifications
You must be signed in to change notification settings - Fork 16
151 lines (121 loc) · 4.13 KB
/
gh-pages.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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
name: Generate and deploy documents
on:
push:
branches:
- master
env:
## コンテキスト
DOCUMENT_BRANCH: "gh-pages"
jobs:
build:
name: Generate document
permissions:
actions: write
checks: write
contents: write
runs-on: ubuntu-22.04
steps:
- name: Set current datetime as env variable
env:
TZ: 'Asia/Tokyo' # Set timezone
run: echo "CURRENT_DATETIME=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
- name: Checkout code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Set git-configs
run: |
git config user.name github-actions
git config user.email github-actions@github.com
git config push.default current
- name: Set whether the branch is already existing to GITHUB_ENV
run: |
branch_is_existing=$(
git fetch origin ${{ env.DOCUMENT_BRANCH }} &&
echo true ||
echo false
)
echo "BRANCH_IS_EXISTING=${branch_is_existing}" >> $GITHUB_ENV
- name: Create branch if not exist
if: env.BRANCH_IS_EXISTING == 'false'
run: |
git switch --orphan ${{ env.DOCUMENT_BRANCH }}
touch .gitkeep
git add .gitkeep
git commit -m "initial commit"
git push
git switch master
- name: Load environment variables from .env file
run: |
for line in $(grep -v '^#' ./doxygen/.env.pages); do
echo $line >> $GITHUB_ENV
done
# - name: check env
# run: printenv
- name: Update submodules
run: git submodule update --init -- "doxygen/doxygen-awesome-css"
- name: Make document (run docker compose)
run: docker compose --env-file .env.pages up && docker compose down
working-directory: ./doxygen
- name: Run after process
run: docker run --rm --name ofr-doc-after -v $GITHUB_WORKSPACE:/usr/src/myapp -w /usr/src/myapp/doxygen python:3.9.16-bullseye python after_process.py $DOXYGEN_HTML_OUTPUT_DIR
- name: Change owner
run: |
sudo chown -R runner:docker ./$DOXYGEN_HTML_OUTPUT_DIR
sudo chown -R runner:docker ./xml
- name: Add Stash
run: |
git add ./$DOXYGEN_HTML_OUTPUT_DIR
git stash push -- ./$DOXYGEN_HTML_OUTPUT_DIR
- name: Reset changes
run: git reset --hard
- name: Switch to document branch
run: git switch ${{ env.DOCUMENT_BRANCH }}
- name: Remove unnecessary files
run: git clean -df
# - name: ls
# run: ls -all
- name: Apply stash
run: git checkout stash -- ./$DOXYGEN_HTML_OUTPUT_DIR
- name: Commit and push
continue-on-error: true
run: |
git add $DOXYGEN_HTML_OUTPUT_DIR/
git commit -m "$CURRENT_DATETIME"
git push
deploy:
name: Deploy pages
needs: build
permissions:
contents: read
pages: write
id-token: write
runs-on: ubuntu-latest
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
steps:
- name: Checkout
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Load environment variables from .env file
run: |
for line in $(grep -v '^#' ./doxygen/.env.pages); do
echo $line >> $GITHUB_ENV
done
- name: Switch to document branch
run: git switch ${{ env.DOCUMENT_BRANCH }}
- name: Setup Pages
uses: actions/configure-pages@v3
# - name: check env
# run: printenv
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
# Upload entire repository
path: ${{ env.DOXYGEN_HTML_OUTPUT_DIR }}
#path: "./testpages"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2