-
Notifications
You must be signed in to change notification settings - Fork 0
68 lines (66 loc) · 2.32 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
name: deploy
on:
workflow_call:
inputs:
version:
description: 'The version to deploy'
required: true
type: string
jobs:
deploy:
strategy:
max-parallel: 1
runs-on: ubuntu-20.04
steps:
- name: get repository files
uses: actions/checkout@v3
- name: the version
run: |
echo "Deploying vanir v${{ inputs.version }}"
- name: install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.DROPLET_PRIVATE_SSH_KEY }}
name: id_rsa
known_hosts: ${{ secrets.DROPLET_KNOWN_HOSTS }}
- name: docker login in droplet
env:
DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }}
DOCKERHUB_TOKEN: ${{ secrets.DOCKERHUB_TOKEN }}
run: |
doctl compute ssh ocean --ssh-command="docker login --username $DOCKERHUB_USERNAME --password $DOCKERHUB_TOKEN"
- name: create env file
env:
ENV_FILE: ${{ secrets.ENV_FILE }}
run: |
doctl compute ssh ocean --ssh-command="rm -f .env"
doctl compute ssh ocean --ssh-command="touch .env"
doctl compute ssh ocean --ssh-command="echo \"$ENV_FILE\" >> .env"
- name: delete previous containers
uses: nick-invision/retry@v2
with:
timeout_minutes: 1
max_attempts: 3
command: |
doctl compute ssh ocean --ssh-command="docker stop vanir || true && docker rm vanir || true"
- name: run container
uses: nick-invision/retry@v2
with:
timeout_minutes: 1
max_attempts: 3
command: |
VERSION=${{ inputs.version }}
doctl compute ssh ocean --ssh-command="docker run -d --name vanir --net senea-network -p 3334:3334 --env-file ./.env brunolombardi/vanir:$VERSION"
- name: health check
uses: nick-invision/retry@v2
with:
timeout_minutes: 1
max_attempts: 3
command: |
REMOTE=$(doctl compute droplet get ocean --template="{{.PublicIPv4}}")
EXIT_CODE=$(ssh root@$REMOTE "APP_NAME=vanir exec bash" < ./.github/scripts/health-check.sh)
exit $EXIT_CODE