-
Notifications
You must be signed in to change notification settings - Fork 6
116 lines (91 loc) · 3.66 KB
/
beta_deployment.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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Beta Deployment
on:
workflow_dispatch:
push:
branches:
- beta
- dev
concurrency: beta-deployment
env:
REGISTRY: registry.digitalocean.com/uoft-orientation
TAG: beta
SERVER_IMAGE_NAME: "orientation-server"
CLIENT_IMAGE_NAME: "orientation-client"
DIGITALOCEAN_API_KEY: ${{ secrets.DIGITALOCEAN_API_KEY }}
jobs:
build_server:
runs-on: ubuntu-20.04
steps:
- name: Checkout code
uses: actions/checkout@v3.5.3
- name: Clean up Docker to free up space
run: |
docker system prune -f
docker volume prune -f
docker image prune -f
- name: Build server image
run: cd server && docker build -t orientation-server:beta -f beta.Dockerfile .
- name: Tag server image
run: docker tag orientation-server:beta registry.digitalocean.com/uoft-orientation/orientation-server:beta
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600
- name: Remove old server image
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $SERVER_IMAGE_NAME)")" ]; then doctl registry repository delete-tag $(echo $SERVER_IMAGE_NAME) $(echo $TAG) --force; else echo "No repository"; fi
- name: Push server image to container registry
run: docker push registry.digitalocean.com/uoft-orientation/orientation-server:beta
build_client:
runs-on: ubuntu-20.04
needs:
- build_server
steps:
- name: Checkout code
uses: actions/checkout@v3.5.3
- name: Clean up Docker to free up space (before build)
run: |
docker system prune -f
docker volume prune -f
docker image prune -f
- name: Make envfile
uses: SpicyPizza/create-envfile@v1.3
with:
envkey_VITE_API_BASE_URL: "https://api.beta.orientation.skule.ca"
file_name: .env
directory: client
- name: Build client image
run: cd client && docker build -t orientation-client:beta -f beta.Dockerfile .
- name: Tag client image
run: docker tag orientation-client:beta registry.digitalocean.com/uoft-orientation/orientation-client:beta
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Log in to DigitalOcean Container Registry
run: doctl registry login --expiry-seconds 600
- name: Remove old client image
run: if [ ! -z "$(doctl registry repository list | grep "$(echo $CLIENT_IMAGE_NAME)")" ]; then doctl registry repository delete-tag $(echo $CLIENT_IMAGE_NAME) $(echo $TAG) --force; else echo "No repository"; fi
- name: Push client image to container registry
run: docker push registry.digitalocean.com/uoft-orientation/orientation-client:beta
- name: Clean up Docker to free up space (after build)
run: |
docker system prune -f
docker volume prune -f
docker image prune -f
# - name: Run garbage collector
# run: doctl registry garbage-collection start --include-untagged-manifests --force uoft-orientation
deploy_beta:
runs-on: ubuntu-20.04
needs:
- build_client
- build_server
steps:
- name: Deploy over SSH
uses: appleboy/ssh-action@v0.1.10
with:
host: beta.orientation.skule.ca
username: ${{ secrets.DO_SSH_USER }}
key: ${{ secrets.DO_SSH_KEY }}
script: ${{ secrets.BETA_DEPLOYMENT_SCRIPT }}