-
Notifications
You must be signed in to change notification settings - Fork 6
108 lines (106 loc) · 3.54 KB
/
deploy.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
name: deploy
on:
push:
branches:
- main
schedule:
- cron: "0 12 * * 1"
workflow_dispatch:
workflow_call:
jobs:
build-node:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: saiemgilani/game-on-paper-app
- name: Publish Node container to GitHub
uses: mr-smithers-excellent/[email protected]
with:
image: saiemgilani/game-on-paper-node
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
directory: ./frontend
dockerfile: ./frontend/Dockerfile
tags: latest
build-python:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: saiemgilani/game-on-paper-app
- name: Publish Python container to GitHub
uses: mr-smithers-excellent/[email protected]
with:
image: saiemgilani/game-on-paper-python
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
directory: ./python
dockerfile: ./python/Dockerfile
tags: latest
build-redis:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
repository: saiemgilani/game-on-paper-app
- name: Publish Redis container to GitHub
uses: mr-smithers-excellent/[email protected]
with:
image: saiemgilani/game-on-paper-redis
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
directory: ./redis
dockerfile: ./redis/Dockerfile.lru
tags: latest
- name: Publish Redis container to GitHub
uses: mr-smithers-excellent/[email protected]
with:
image: saiemgilani/game-on-paper-cache
registry: ghcr.io
username: ${{ secrets.GH_USERNAME }}
password: ${{ secrets.GITHUB_TOKEN }}
directory: ./redis
dockerfile: ./redis/Dockerfile.cache
tags: latest
deploy:
runs-on: ubuntu-latest
needs:
- build-node
- build-python
- build-redis
steps:
- uses: actions/checkout@v3
with:
repository: saiemgilani/game-on-paper-app
- name: Push updated docker-compose override file
uses: vtisweden/[email protected]
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
localPath: './docker-compose.do.yml'
remotePath: './docker-compose.yml'
- name: Deploy package to DigitalOcean
uses: appleboy/ssh-action@master
env:
GITHUB_USERNAME: ${{ secrets.GH_USERNAME }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DOCKER_COMPOSE_FILE: ${{ env.DOCKER_COMPOSE_FILE }}
DOCKER_COMPOSE_OVERRIDE_FILE: ${{ env.DOCKER_COMPOSE_OVERRIDE_FILE }}
with:
host: ${{ secrets.HOST }}
username: ${{ secrets.USERNAME }}
password: ${{ secrets.PASSWORD }}
port: ${{ secrets.PORT }}
envs: GITHUB_USERNAME, GITHUB_TOKEN, DOCKER_COMPOSE_FILE, DOCKER_COMPOSE_OVERRIDE_FILE
script: |
docker stop $(docker ps -a -q)
docker system prune --force
docker login ghcr.io -u $GITHUB_USERNAME -p $GITHUB_TOKEN
docker-compose pull
docker-compose -f docker-compose.yml up -d