-
Notifications
You must be signed in to change notification settings - Fork 41
80 lines (65 loc) · 2.36 KB
/
deploy-staging.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
name: Deploy to staging
# on:
# release:
# types: [published]
on:
push:
branches: [ "staging-deploy" ]
jobs:
deploy-static:
permissions:
contents: 'read'
id-token: 'write'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
# - name: Set up Node.js
# uses: actions/setup-node@v4
# with:
# node-version: '14.x'
# - run: |
# npm install
# npm install -g gulp
# npm rebuild node-sass
# gulp build
# working-directory: ubyssey/static_src
# - name: Set up Python
# uses: actions/setup-python@v5
# with:
# python-version: '3.9'
# - name: Install Python dependencies
# run: python -m pip install -r requirements.txt
# - name: Collect Django static files
# run: DJANGO_SETTINGS_MODULE=config.settings.base python manage.py collectstatic --noinput
- uses: 'google-github-actions/auth@v2'
with:
workload_identity_provider: 'projects/1012602718138/locations/global/workloadIdentityPools/ubyssey-wif-pool-staging/providers/ubyssey-oidc-github-staging'
service_account: '[email protected]'
# - uses: 'google-github-actions/upload-cloud-storage@v2'
# with:
# path: 'static'
# destination: 'ubyssey-staging'
- name: Configure SSH
run: |
mkdir -p ~/.ssh/
echo "$SSH_KEY" > ~/.ssh/staging.key
chmod 600 ~/.ssh/staging.key
cat >>~/.ssh/config <<END
Host staging
HostName $SSH_HOST
User $SSH_USER
IdentityFile ~/.ssh/staging.key
StrictHostKeyChecking no
END
env:
SSH_USER: deploy
SSH_KEY: ${{ secrets.GCP_SSH_PRIVATE_KEY_STAGING }}
SSH_HOST: ${{ secrets.GCP_SSH_HOST_STAGING }}
- name: Update environment variables
run: ssh staging 'export $(gcloud secrets versions access latest --secret="${SECRET_NAME}" | xargs)'
env:
SECRET_NAME: ${{ secrets.GCP_ENV_CONFIGS_SECRET_NAME }}
- name: Update docker-compose.yml
run: scp docker-compose.yml staging:/opt/ubyssey.ca/docker-compose.yml
- name: Restart services
run: ssh staging 'docker compose -f /opt/ubyssey.ca/docker-compose.yml -p ubyssey up -d'