-
Notifications
You must be signed in to change notification settings - Fork 0
70 lines (62 loc) · 2.38 KB
/
main.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
# Workflow Name
name: Compile Updated Website
# Control when the action will run:
on:
push:
branches: [ main ]
# Allows you to run this workflow manually from the Actions tab on GitHub
workflow_dispatch:
# Controls what to do:
jobs:
compile: # Used as the job name if the workflow wasn't named
# Stop if the commit message that triggered this workflow contains the words "skip ci"
if: "!contains(github.event.commits[0].message, 'skip ci')"
runs-on: ubuntu-latest
steps:
# Add and setup Node
- uses: actions/checkout@v2
- name: Install Node v14.#.#
uses: actions/setup-node@v2
with:
node-version: '14'
# Using the commit that triggered this workflow run the JamED compiler
- name: Compiling website
run: |
node ./bin/cli compile
echo "Stash release files up 1 directory"
mv release/ ../release
# Create a shell script that creates the website branch if it does not exist
- name: Checking if website branch exists
run: |
git config --global user.name "$(git --no-pager log --format=format:'%an' -n 1)"
git config --global user.email "$(git --no-pager log --format=format:'%ae' -n 1)"
touch wbc.sh
echo "#!/bin/bash" >> wbc.sh
echo "check=\"$(git ls-remote --heads | grep website)"\" >> wbc.sh
echo "if [ -z \"\$check\" ]" >> wbc.sh
echo "then" >> wbc.sh
echo " echo \"Website branch does not exist, creating now\"" >> wbc.sh
echo " git checkout -b website" >> wbc.sh
echo " git push --set-upstream origin website" >> wbc.sh
echo "else" >> wbc.sh
echo " echo \"Website branch exists\"" >> wbc.sh
echo "fi" >> wbc.sh
chmod +x wbc.sh
./wbc.sh
rm wbc.sh
# Checkout the website (gh pages) branch
- name: Checkout website branch
uses: actions/checkout@v2
with:
ref: website
# Delete all files in the website branch and replace with the files we just compiled
- name: Pushing to gh pages
run: |
rm * -r
git rm -r --cached .
echo "Copy release files into website branch"
cp ../release/* . -r
rm ../release -r
git add .
git commit -m "workflow auto compile website"
git push