-
Notifications
You must be signed in to change notification settings - Fork 0
109 lines (101 loc) · 4.45 KB
/
Copy pathcodesAPI_CI.yml
File metadata and controls
109 lines (101 loc) · 4.45 KB
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
# Workflow to build and deploy designer dashboard to server.
name: OpenGameData Codes API CI
on:
# push:
# paths:
# - '.github/workflows/codesAPI_CI.yml'
# - '.github/actions/**'
# - 'config/**'
# - 'apis/codes/**'
# - 'codes_app.py'
workflow_dispatch: # Allow manual trigger of this workflow from the Actions tab
env:
DEPLOY_HOST: ${{ vars.OGD_STAGING_HOST }}
DEPLOY_DIR: ${{ vars.WSGI_PATH }}/${{ github.event.repository.name }}/${{ github.ref_name }}/codes
DEPLOY_URL: ${{ vars.OGD_STAGING_HOST }}/wsgi-bin/${{ github.event.repository.name }}/${{ github.ref_name }}/codes
URL_PATH: wsgi-bin/${{ github.event.repository.name }}/${{ github.ref_name }}/codes
jobs:
ci_deploy:
name: CI Deploy of Coding API
runs-on: ubuntu-22.04
steps:
# 1. Local checkout & config
- uses: actions/checkout@v4
- name: Set up Config File
uses: ./.github/actions/API_config
with:
db_host: ${{ vars.OGD_LOGGER_HOST }}
db_user: ${{secrets.SQL_USER}}
db_pass: ${{secrets.SQL_PASS}}
id_gen_db_name: ${{ secrets.DBNAME_ID_GEN }}
fd_users_db_name: ${{ secrets.DBNAME_FD_USERS }}
app_path: "apps/coding/codes.wsgi"
deploy_path: ${{ env.DEPLOY_DIR }}
- name: Set up Core Config File
uses: ./.github/actions/OGD_config
with:
sql_user: ${{ secrets.SQL_USER }}
sql_pass: ${{ secrets.SQL_PASS }}
ssh_host: ${{ vars.OGD_LOGGER_HOST }}
ssh_user: ${{ secrets.VPN_USER }}
ssh_pass: ${{ secrets.VPN_PASS }}
slice_size: 1000
log_level: "INFO"
# 2. Build
# 3. Remote config & deploy
- name: Install OpenConnect
run: sudo apt-get -q update && sudo apt-get -q install openconnect
- name: Connect VPN
run: echo ${{ secrets.VPN_PASS }} | sudo openconnect --protocol=gp -u ${{ secrets.VPN_USER }} --passwd-on-stdin soe.vpn.wisc.edu &
- name: Setup Access Key
run: |
mkdir -p ~/.ssh
echo '${{secrets.DEPLOY_KEY}}' >> ./key.txt
chmod 600 ./key.txt
- name: Ensure directory exists
run: ssh -o StrictHostKeyChecking=no -T -i ./key.txt ${{ secrets.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} "mkdir -p ${{ env.DEPLOY_DIR }}"
- name: Upload *shared code* to web server via rsync
uses: burnett01/rsync-deployments@5.2
with:
# switches:
# -v : verbose output
# -r : recurse into subdirectories
# -c : use checksum to determine what files to update/skip
# -t : preserve modification times
# --delete : delete extraneous files from destination directories
# --exclude-from : skip any files in rsync-exclude
# --chmod : For each directory (D) and file (F), give user (u) and group (g) rwx permissions.
# Give others (o) only read permissions, plus execute for directories.
switches: -vrct --delete --exclude-from 'rsync-exclude' --chmod=Du=rwx,Dg=rwx,Do=rx,Fu=rwx,Fg=rwx,Fo=r
path: ./src
remote_path: ${{ env.DEPLOY_DIR }}/shared
remote_host: ${{ env.DEPLOY_HOST }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.DEPLOY_KEY }}
- name: Upload API to web server via rsync
uses: burnett01/rsync-deployments@5.2
with:
# switches:
# -v : verbose output
# -r : recurse into subdirectories
# -c : use checksum to determine what files to update/skip
# -t : preserve modification times
# --delete : delete extraneous files from destination directories
# --exclude-from : skip any files in rsync-exclude
# --chmod : For each directory (D) and file (F), give user (u) and group (g) rwx permissions.
# Give others (o) only read permissions, plus execute for directories.
switches: -vrct --delete --exclude-from 'rsync-exclude' --chmod=Du=rwx,Dg=rwx,Do=rx,Fu=rwx,Fg=rwx,Fo=r
path: apps/coding/*
remote_path: ${{ env.DEPLOY_DIR }}
remote_host: ${{ env.DEPLOY_HOST }}
remote_user: ${{ secrets.DEPLOY_USER }}
remote_key: ${{ secrets.DEPLOY_KEY }}
# 4. Cleanup & complete
- name: Trigger Graceful Reboot
run: ssh -o StrictHostKeyChecking=no -T -i ./key.txt ${{ secrets.DEPLOY_USER }}@${{ env.DEPLOY_HOST }} "sudo apachectl -k graceful"
- name: Announce deploy
run: echo "Deployed to ${{ env.DEPLOY_URL }}"
- name: Upload logs as artifacts
uses: actions/upload-artifact@v2
with:
path: ./*.log