-
Notifications
You must be signed in to change notification settings - Fork 113
200 lines (170 loc) · 5.37 KB
/
Copy pathdeploy.yml
File metadata and controls
200 lines (170 loc) · 5.37 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
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
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
---
name: deploy
on:
push:
branches:
- master
- "[0-9]+.[0-9]+"
pull_request:
branches:
- master
- "[0-9]+.[0-9]+"
env:
RUBY_VERSION: 3.1
BUNDLE_WITHOUT: "nanoc"
MAKE_J: 3
jobs:
build-ccutil:
runs-on: ubuntu-24.04
container:
image: quay.io/ivanhorvath/ccutil:amazing
steps:
- name: Checkout
uses: actions/checkout@v7
- name: Compile html-single
run: make -C guides ccutil -j ${{ env.MAKE_J }}
build-html:
runs-on: ubuntu-24.04
defaults:
run:
shell: bash
steps:
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Checkout
uses: actions/checkout@v7
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Build HTML with real links
run: |
make clean
make -j ${{ env.MAKE_J }} html
- name: Upload HTML
uses: actions/upload-artifact@v7
with:
name: foreman-docs-html-${{ env.BRANCH_NAME }}
path: guides/build/
pr-metadata:
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
steps:
- name: Get branch name (pull request)
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Set target name (master)
if: github.base_ref == 'master'
run: echo "TARGET_NAME=nightly" >> $GITHUB_ENV
- name: Set target name (stable branch)
if: github.base_ref != 'master'
run: echo "TARGET_NAME=$(echo ${GITHUB_BASE_REF} | tr / -)" >> $GITHUB_ENV
- name: Save PR metadata
run: |
mkdir -p ./pr
echo '{"pr_number": ${{ github.event.number }}, "branch_name": "${{ env.BRANCH_NAME }}", "target_name": "${{ env.TARGET_NAME }}", "head_sha": "${{ github.event.pull_request.head.sha }}"}' > ./pr/pr.json
- uses: actions/upload-artifact@v7
with:
name: pr
path: ./pr/
build-html-base:
runs-on: ubuntu-24.04
if: github.event_name == 'pull_request'
defaults:
run:
shell: bash
steps:
- name: Checkout
uses: actions/checkout@v7
with:
ref: ${{ github.base_ref }}
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
- name: Build HTML base for comparison
run: |
make clean
make -j ${{ env.MAKE_J }} html
- name: Upload HTML base for comparison
uses: actions/upload-artifact@v7
with:
name: foreman-docs-html-base
path: guides/build/
build-web:
runs-on: ubuntu-24.04
steps:
- name: Checkout master
if: github.event_name != 'pull_request' || github.base_ref != 'master'
uses: actions/checkout@v7
with:
ref: master
- name: Checkout PR
if: github.event_name == 'pull_request' && github.base_ref == 'master'
uses: actions/checkout@v7
- name: Setup Ruby
uses: ruby/setup-ruby@v1
with:
ruby-version: ${{ env.RUBY_VERSION }}
bundler-cache: true
working-directory: ./web
- name: Build site with nanoc
run: bundle exec nanoc
working-directory: ./web
- name: Upload web
uses: actions/upload-artifact@v7
with:
name: foreman-docs-web-master
path: web/output/
publish:
if: >
github.repository_owner == 'theforeman' &&
(github.ref == 'refs/heads/master' ||
startsWith(github.ref, 'refs/heads/2.') ||
startsWith(github.ref, 'refs/heads/3.'))
needs:
- build-html
- build-web
- build-ccutil
runs-on: ubuntu-24.04
concurrency:
group: gh-pages-deploy
cancel-in-progress: false
defaults:
run:
shell: bash
steps:
- name: Get branch name (merge)
if: github.event_name != 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_REF#refs/heads/} | tr / -)" >> $GITHUB_ENV
- name: Get branch name (pull request)
if: github.event_name == 'pull_request'
run: echo "BRANCH_NAME=$(echo ${GITHUB_HEAD_REF} | tr / -)" >> $GITHUB_ENV
- name: Create public directory
run: mkdir -p public/${{ env.BRANCH_NAME }}
- name: Download web (only for master)
if: github.ref == 'refs/heads/master'
uses: actions/download-artifact@v8
with:
name: foreman-docs-web-${{ env.BRANCH_NAME }}
path: public
- name: Download HTML
uses: actions/download-artifact@v8
with:
name: foreman-docs-html-${{ env.BRANCH_NAME }}
path: public/${{ env.BRANCH_NAME }}
- name: Rename master to nightly
if: github.ref == 'refs/heads/master'
run: mv master nightly
working-directory: ./public
- name: Deploy
uses: peaceiris/actions-gh-pages@v4.1.0
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
publish_dir: ./public
keep_files: true