-
Notifications
You must be signed in to change notification settings - Fork 0
120 lines (91 loc) · 3.52 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
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
name: Build Test And Deploy
on:
push:
branches:
- dev
paths_ignore:
- '*.md'
- 'dist/*'
jobs:
chore:
name: Main Job
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@master
- name: Setting up the environment
run: |
git config user.name "Husam's Bot"
git config user.email "husamsbot@gmail.com"
git pull
yarn remove husky
yarn
- name: Building the vue-ish bundle and demo files
run: yarn build
- name: Running tests
env:
CODECOV_TOKEN: ${{ secrets.CodecovToken }}
run: |
yarn test:cover
# upload coverage results to codecov
bash <(curl -s https://codecov.io/bash)
- name: Creating PRs to deploy to GitHub Pages and update dist folder (if needed)
env:
BOT_TOKEN: ${{ secrets.BotToken }}
run: |
cp -r dist tmp
# stash away newly generated files
git stash
######################################
# UPDATE DIST FOLDER #
######################################
TIMESTAMP=`date +%s`
BRANCH_NAME=`echo update-dist-$TIMESTAMP`
git checkout -b $BRANCH_NAME
rm -rf dist && cp -r tmp dist
git add dist
# 'git commit' will exit with a non-zero code if there's nothing to commit
set +e
git commit -m "chore: update dist folder 🤖"
COMMIT_EXIT_CODE=`echo $?` # $? is the exit code of the last command
set -e
if [ $COMMIT_EXIT_CODE -eq 0 ]; then
git push --set-upstream "https://husams-bot:${BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" $BRANCH_NAME
# create a pull request
curl -X POST \
-u husams-bot:${BOT_TOKEN} \
-H "Accept: application/vnd.github.v3+json" \
-d "{ \
\"title\": \"chore: update dist folder\", \
\"head\": \"${BRANCH_NAME}\", \
\"base\": \"dev\", \
\"body\": \"This is an automated PR. Beep beep!\" \
}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"
fi
######################################
# UPDATE GH-PAGES DEMO FILES #
######################################
BRANCH_NAME=`echo update-ghpages-$TIMESTAMP`
git checkout gh-pages
git checkout -b $BRANCH_NAME
cp -rf tmp/demo/. .
git add index.html css fonts js
# 'git commit' will exit with a non-zero code if there's nothing to commit
set +e
git commit -m "chore: update demo files 🤖"
COMMIT_EXIT_CODE=`echo $?` # $? is the exit code of the last command
set -e
if [ $COMMIT_EXIT_CODE -eq 0 ]; then
git push --set-upstream "https://husams-bot:${BOT_TOKEN}@github.com/${GITHUB_REPOSITORY}.git" $BRANCH_NAME
# create a pull request
curl -X POST \
-u husams-bot:${BOT_TOKEN} \
-H "Accept: application/vnd.github.v3+json" \
-d "{ \
\"title\": \"chore: update demo files\", \
\"head\": \"${BRANCH_NAME}\", \
\"base\": \"gh-pages\", \
\"body\": \"This is an automated PR. Beep beep!\" \
}" \
"https://api.github.com/repos/${GITHUB_REPOSITORY}/pulls"
fi