-
Notifications
You must be signed in to change notification settings - Fork 484
60 lines (51 loc) · 1.75 KB
/
build.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
name: Test Build
on: [push, pull_request]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout Hugo Site
uses: actions/checkout@v2
with:
repository: prestashop/devdocs-site
submodules: true
- name: Checkout PR
uses: actions/checkout@v2
with:
path: _current/
- name: Setup Hugo
uses: peaceiris/actions-hugo@v2
with:
hugo-version: '0.85.0'
extended: true
- name: Find version from branch name (pull request)
if: ${{ github.event_name == 'pull_request' }}
env:
TARGET_BRANCH: ${{ github.base_ref }}
# transform "1.7.x" in "1.7"
run: |
echo "VERSION=`echo $TARGET_BRANCH | perl -pe 's|^([\d.]+)(?:\.x)?$|\1|'`" >> $GITHUB_ENV;
- name: Find version from branch name (push)
if: ${{ github.event_name != 'pull_request' }}
env:
TARGET_BRANCH: ${{ github.ref }}
# transform "refs/heads/1.7.x" in "1.7"
run: |
echo "VERSION=`echo $TARGET_BRANCH | perl -pe 's|^.+/([^/]+?)(?:\.x)?$|\1|'`" >> $GITHUB_ENV;
- name: Ensure the version is coherent
run: |
VERSION_FORMAT='^([0-9]+\.)*[0-9]+$'
if [[ ! $VERSION =~ $VERSION_FORMAT ]]; then
echo "::error::Version '$VERSION' is not a valid version!"
exit 1
else
echo "Version: '$VERSION'"
fi
- name: Move content into the appropriate directory
run: |
[[ -d "src/content/$VERSION" ]] && rm -rf "src/content/$VERSION";
mv _current "src/content/$VERSION"
- name: Build
env:
DEVDOCS_GITHUB_READ_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: cd src/ && hugo