-
Notifications
You must be signed in to change notification settings - Fork 0
86 lines (75 loc) · 2.71 KB
/
github-action.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
name: github-actions
on:
push:
branches:
- master
repository_dispatch:
type:
- submit-request
jobs:
Send_To_MongoDB:
if: github.event_name == 'repository_dispatch'
runs-on: ubuntu-latest
steps:
- name: Questionnaires data
if: github.event.client_payload.questionnaires != ''
run: |
SECRET_VALUE=$(cat $GITHUB_EVENT_PATH | jq -r '.client_payload.questionnaires' )
echo "::add-mask::$SECRET_VALUE"
echo $SECRET_VALUE > questionnaires.json
- name: Users data
if: github.event.client_payload.users != ''
run: |
SECRET_VALUE=$(cat $GITHUB_EVENT_PATH | jq -r '.client_payload.users' )
echo "::add-mask::$SECRET_VALUE"
echo $SECRET_VALUE > users.json
- name: Cache MongoDB tools
id: mongodb-tool-cache
uses: actions/cache@v3
with:
path: ~/bin/mongo*
key: ${{ runner.os }}-mongodb-database-tools
- if: ${{ steps.mongodb-tool-cache.outputs.cache-hit != 'true' }}
name: Install MongoDB tools
env:
EBE_FILE_NAME: mongodb-database-tools-ubuntu2004-x86_64-100.8.0.deb
run: |
sudo apt-get update && sudo apt-get -y install curl
curl -O https://fastdl.mongodb.org/tools/db/${{ env.EBE_FILE_NAME }} && sudo apt install ./${{ env.EBE_FILE_NAME }}
mkdir -p ~/bin
cp /usr/bin/mongo* ~/bin
- name: Insert questionnaires to MongoDB
if: github.event.client_payload.questionnaires != ''
run: |
~/bin/mongoimport '${{ secrets.MONGODB_ATLAS_CONN_STR }}' --db=2024-sitcon --collection=questionnaires --mode=insert --type=json --file=questionnaires.json
- name: Insert personal information to MongoDB
if: github.event.client_payload.users != ''
run: |
~/bin/mongoimport '${{ secrets.MONGODB_ATLAS_CONN_STR }}' --db=2024-sitcon --collection=users --mode=insert --type=json --file=users.json
Build_And_Deploy:
if: github.event_name == 'push'
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- name: Checkout code
uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_REF_NAME }}
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: "20.x"
- name: Install dependencies
run: npm install
- name: Build
env:
HASH_ROUTER: true
run: npm run build
- name: Deploy
uses: JamesIves/github-pages-deploy-action@v4
with:
branch: gh-pages
folder: ./build
git-config-name: "GitHub Actions Deploy"
commit-message: "release: v1.0.${{ github.run_number }}"