-
Notifications
You must be signed in to change notification settings - Fork 29
204 lines (163 loc) · 6.58 KB
/
previewPR.yml
File metadata and controls
204 lines (163 loc) · 6.58 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
201
202
203
204
name: previewPR
env:
PR_NUMBER: ${{github.event.number}}
on:
pull_request_target
jobs:
setup-matrix:
runs-on: ubuntu-latest
steps:
- name: Checkout solutions
uses: actions/checkout@v2
- name: Install node environment
uses: actions/setup-node@v2-beta
- name: npm install
run: |
cd scripts
npm install
cd ../
- name: Select Changed Files
id: changedfiles
run: |
echo $GITHUB_REPOSITORY
cd scripts
node changedFilesSolutions.js
cd ../
env:
PR_OWNER: ${{ github.repository_owner }}
PR_REPO: ${{ github.event.repository.name }}
- name: Setup matrix combinations
id: setup-matrix-combinations
run: |
dirs=()
for changed_file in ${{ steps.changedfiles.outputs.changedFiles }}; do
dir="$(echo $changed_file | cut -d/ -f2)"
check="$(echo $changed_file | cut -d/ -f1)"
if [[ ! " ${dirs[@]} " =~ " ${dir} " ]]; then
if [[ "$check" == *"solution"* ]]; then
MATRIX_PARAMS_COMBINATIONS=$MATRIX_PARAMS_COMBINATIONS'{"solution": "'$dir'"},'
dirs+=($dir)
fi
fi
done
echo ::set-output name=matrix-combinations::{\"include\":[$MATRIX_PARAMS_COMBINATIONS]}
if [ "$MATRIX_PARAMS_COMBINATIONS" == "" ]; then
echo empty Matrix
MATRIX_PARAMS_COMBINATIONS=$MATRIX_PARAMS_COMBINATIONS'{"solution": "'noChange'"}'
echo ::set-output name=matrix-combinations::{\"include\":[$MATRIX_PARAMS_COMBINATIONS]}
else
echo filled Matrix
fi
outputs:
matrix-combinations: ${{ steps.setup-matrix-combinations.outputs.matrix-combinations }}
build:
runs-on: ubuntu-latest
needs: setup-matrix
strategy:
matrix: ${{ fromJson(needs.setup-matrix.outputs.matrix-combinations) }}
steps:
- name: Clone
uses: actions/checkout@v2
with:
repository: devonfw/devonfw.github.io
ref: develop
submodules: true
- name: Remove old Solutions
run: rm -rf solutions
- name: Add new solutions
uses: actions/checkout@v2
with:
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
path: solutions
- name: Cache local Maven repository
uses: actions/cache@v2
with:
path: ~/.m2/repository
key: ${{ runner.os }}-maven-${{ hashFiles('**/pom.xml') }}
restore-keys: |
${{ runner.os }}-maven-
- name: Setup Node
uses: actions/setup-node@v2
- name: Solutions from Stack repositories
run: |
cd solutions/scripts
npm install
node copySolutionsFromStack.js ../../devonfw-guide
cd ../../
- name: Copy pom files for solutions
run: |
chmod +x solutions/scripts/copyPomFiles.sh
solutions/scripts/copyPomFiles.sh
- name: Copy pom files for tutorials
run: |
chmod +x wiki-tutorials/scripts/copyPomFiles.sh
wiki-tutorials/scripts/copyPomFiles.sh
- name: npm install for solutions
run: |
cd solutions/scripts
npm install
cd ../../
- name: Fix includes
run: |
node solutions/scripts/fixIncludeFiles.js ./solutions/solutions/ ./solutions/includes/
- name: Fix includes
run: |
node solutions/scripts/fixIncludeFiles.js ./solutions/solutions/ ./solutions/includes/
- name: Compile sass for solutions
uses: gha-utilities/sass-build@v0.4.2
with:
source: solutions/index.scss
destination: solutions/index.css
- name: Compile sass for tutorials
uses: gha-utilities/sass-build@v0.4.2
with:
source: wiki-tutorials/index.scss
destination: wiki-tutorials/index.css
- name: Remove files that are breaking the build
run: |
rm solutions/README.md || true
rm solutions/index.scss || true
rm wiki-tutorials/README.md || true
rm wiki-tutorials/index.scss || true
- name: Build
run: mvn -s ./.m2/unblock-rubygem-proxy-settings.xml clean package
- name: Create output for solutions
run: |
chmod +x solutions/scripts/createOutput.sh
solutions/scripts/createOutput.sh
- name: Copy output of solutions
run: |
cp -avr solutions/target/generated-docs/ target/generated-docs/website/pages/solutions/
- name: Run image generate
run: |
if [ "${{ matrix.solution }}" == "noChange" ]; then
echo ${{ matrix.solution }}
else
if [[ -d "target/generated-docs/website/pages/solutions/solutions/${{ matrix.solution }}" ]]; then
mv target/generated-docs/website/pages/solutions/solutions/${{ matrix.solution }}/index.html target/generated-docs/website/pages/solutions/solutions/${{ matrix.solution }}/${{ matrix.solution }}.html
cd target/generated-docs/website/pages/solutions/solutions/${{ matrix.solution }}
npm install --global pageres-cli
pageres ${{ matrix.solution }}.html 1280x800 --format=png --filename="${{ matrix.solution }}"
else
echo No Directory
fi
fi
- name: Artifact build upload
uses: actions/upload-artifact@v2
with:
name: my-artifact
path: target/generated-docs/website/pages/solutions/solutions/${{ matrix.solution }}/${{ matrix.solution }}.png
if-no-files-found: ignore
comment:
needs: build
runs-on: ubuntu-latest
steps:
- name: Upload Comment
uses: mshick/add-pr-comment@v1
with:
message: |
the artifact has been generated and you can find a preview of your change here: Actions - select your pull request workflow - scroll to the bottom, there you should be able to download the artifact (only works if something has been changed in solutions)
repo-token: ${{ secrets.GITHUB_TOKEN }}
repo-token-user-login: 'github-actions[bot]'
allow-repeats: true