-
Notifications
You must be signed in to change notification settings - Fork 0
72 lines (66 loc) · 3.03 KB
/
Obfuscate JS and Deploy to Preview.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
name: Obfuscate JS and Deploy to Preview
on:
push:
branches:
- '*-prv'
- '*-preview'
- '!*-npv'
- '!*-nopreview'
- '!main'
- '!master'
workflow_dispatch:
jobs:
build:
runs-on: ubuntu-latest
continue-on-error: true
steps:
- name: Get repository from repo server to runner
uses: actions/checkout@v2
- name: Obfuscate codes
run: |
npm i -g javascript-obfuscator
cp -r ./development/public ./preview/
javascript-obfuscator ./preview/public/ --output ./preview/public/
- name: List development files
run: |
echo -e "Built on $(date)\n" | tee ./preview/preview.build.list
echo "Readable code sizes:" | tee -a ./preview/preview.build.list
du -ha ./development/public/ | grep "\.js" | tee -a ./preview/preview.build.list
echo | tee -a ./preview/preview.build.list
- name: List preview files
run: |
echo "Obfuscated code sizes:" | tee -a ./preview/preview.build.list
du -ha ./preview/public/ | grep "\.js" | tee -a ./preview/preview.build.list
echo | tee -a ./preview/preview.build.list
- name: Install Firebase tools
run: |
npm i -g firebase-tools
- name: Deploy to preview
run: |
cd ./preview
firebase use sozialm --token "${{ secrets.FIREBASE_TOKEN }}"
# generate CHANNEL_ID
CHANNEL_ID=$(git branch --show-current | sed "s/\//-/g")-$(date | sed "s/\s//g" | sed "s/://g")
echo "channel = $CHANNEL_ID"
# run firebase and store the output in a variable
DEPLOY_MESSAGE="$(firebase hosting:channel:deploy -e 2d $CHANNEL_ID --token ${{ secrets.FIREBASE_TOKEN }})"
echo "$DEPLOY_MESSAGE"
# extract the URL_STRING - string containing the URL.
URL_STRING=$(echo "$DEPLOY_MESSAGE" | grep -i "\-$CHANNEL_ID\-")
echo "url_string = $URL_STRING"
# extract the PREVIEW_URL - the actual URL.
PREVIEW_URL=$(echo "$URL_STRING" | cut -d " " -f 7)
echo "URL: $PREVIEW_URL" | tee -a ./preview.build.list
echo | tee -a ./preview.build.list
cd ../
- name: Delete preview files
run: |
rm -rf ./preview/public/*
- name: Git commit and push
run: |
git config --global user.name "CinexSoft"
git config --global user.email "cinexsoft@gmail.com"
COMMIT_M=$(cat ./preview/preview.build.list | tail -n 2 | grep "\.web\.app")
git add -A | tee -a ./preview/preview.build.list
git commit -m "deployed to preview: $COMMIT_M" -m "$COMMIT_M" | tee -a ./preview/preview.build.list
git push | tee -a ./preview/preview.build.list