-
Notifications
You must be signed in to change notification settings - Fork 0
93 lines (75 loc) · 2.51 KB
/
build-dist-folder.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
82
83
84
85
86
87
88
89
90
91
92
93
## git: https://github.com/pffy/code-gs
## lic: https://unlicense.org/
## task: concat src/*.gs files into dist/code.gs
## task: move src/*.html to dist folder (optional)
## task: move src/appsscript.json to dist folder (optional)
name: build dist folder
on:
push:
paths:
- 'src/*.gs'
- 'src/*.html'
- 'src/appsscript.json'
branches:
- 'main'
jobs:
build_dist:
runs-on: ubuntu-latest
steps:
- name: checkout
uses: actions/checkout@v3
- name: concat gs files to code-gs
run: |
ls
pwd
## get concat helper text files
git clone https://github.com/pffy/nip
## get the file location for horizontal rule
HR=$PWD/nip/js/hr80.js
echo $HR
## from the repo root, list gs files in 'src' with commas
FF=$(ls -1 src/*.gs | tr "\n" ",")
echo $FF
## based on solution found here:
## https://stackoverflow.com/a/27658733
## removes last comma
FF=${FF::-1}
echo $FF
## based on this solutions:
## https://stackoverflow.com/a/13210909
## replace the commas with file name of HR80
FF=${FF//,/ $HR }
echo $FF
OUTFILE=code.gs
## build a new outfile
rm -f $OUTFILE
echo "/* $OUTFILE generated by concat-gs-files workflow: gh/pffy/code-gs */" >> $OUTFILE
echo "" >> $OUTFILE
cat $FF >> $OUTFILE
pwd
## finish, move outfile and support files to `dist` folder
rm -rf dist
mkdir -p dist
mv code.gs ./dist
## based on solution found here:
## https://stackoverflow.com/a/17902999
## HTML files are optional
HTML=./src/*.html
[[ $(ls $HTML) ]] && cp $HTML ./dist || echo "no-html-files"
## JSON files are optional
JSON=./src/appsscript.json
[[ $(ls $JSON) ]] && cp $JSON ./dist || echo "no-json-file"
## cleanup
rm -rf nip
- name: show a tree
run: |
tree .
- name: setup git config
run: |
git config user.name "GitHub Actions Bot"
git config user.email "<>"
- name: commit
run: |
git add .
git commit -m "generated by build-dist-folder workflow"
git push origin main