-
Notifications
You must be signed in to change notification settings - Fork 54
81 lines (71 loc) · 3.41 KB
/
build-preview-pages.yaml
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
name: Build site preview
on:
pull_request:
branches:
- master
push:
branches:
- '*'
- '!master'
jobs:
# This job is only temporary solution until a new Jekyll builder (Dockerfile) is
# created. Then the logic will be reworked.
buildMachinekitSite:
runs-on: ubuntu-latest
env:
ACTING_SHA: ${{ github.sha }}
OUTPUT_NAME: 'machinekit-site-${{ github.sha }}'
ACTING_REPOSITORY: ${{ github.repository }}
steps:
# Locally clone the repository which we want to build with depth of 5 commits
- name: Checkout the pull request for Machinekit-docs
uses: actions/checkout@v2
with:
repository: '${{ env.ACTING_REPOSITORY }}'
ref: ${{ env.ACTING_SHA }}
path: to_build
fetch-depth: '5'
- name: Git SHA on which the build is requested
run: echo ${{ env.ACTING_SHA }}
- name: Git log of repository on which the build is requested
run: git log
working-directory: ./to_build
# Create directory for output files and export it's name as a environment variable
- name: Create output directory
run: |
mkdir ./${{ env.OUTPUT_NAME }}
echo "OUTPUT_DIRECTORY=$(pwd)/${{ env.OUTPUT_NAME }}" >> "$GITHUB_ENV"
echo "The output directory is ${{ env.OUTPUT_DIRECTORY }}"
mkdir ./${{ env.OUTPUT_NAME }}/build
# The commits pushed to gh-pages branch will appear as originated from the author
# of the changes
- name: Create JSON with commit metadata
env:
FILENAME: '$OUTPUT_DIRECTORY/build-metadata.json'
run: |
echo "###########################################################"
echo "# Commit which will be used for mining of the credentials #"
echo "###########################################################"
git log -n 1 --no-merges HEAD
jq -n --arg authoremail "$(git log --format='%ae' -n 1 --no-merges HEAD)" --arg authorname "$(git log --format='%an' -n 1 --no-merges HEAD)" --arg commitmsg "$(git log --format='%B' -n 1 --no-merges HEAD)" --arg sha "${{ env.ACTING_SHA }}" '{"author":"\($authorname)","email":"\($authoremail)","message":"\($commitmsg)","sha":"\($sha)"}' > ${{ env.FILENAME }}
echo "###########################################################"
echo "# JSON file with metadata information of pertinent commit #"
echo "###########################################################"
echo "Whole path: ${{ env.FILENAME }}"
echo ""
cat ${{ env.FILENAME }}
working-directory: ./to_build
# Running the commands in ubuntu-master and not in Docker container because
# of the age of the container -> It cannot be even build anymore
- name: Run the Jekyll builder
run: docker run -v $(pwd)/to_build:/work haberlerm/docker-jekyll-asciidoctor jekyll build --verbose --trace --config _config.yml,_config_devel.yml
- name: Print newly created files
run: find . -print0 | xargs -0 -I '{}' ls --color -d '{}'
working-directory: ./to_build
- name: Copy the newly generated site to output directory
run: cp -r to_build/_site/* ${{ env.OUTPUT_DIRECTORY }}/build
- name: Upload the artifact
uses: actions/upload-artifact@v1
with:
name: ${{ env.OUTPUT_NAME}}
path: ${{ env.OUTPUT_DIRECTORY}}