-
Notifications
You must be signed in to change notification settings - Fork 0
110 lines (93 loc) · 2.96 KB
/
Copy pathdeploy.yml
File metadata and controls
110 lines (93 loc) · 2.96 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
110
name: Deploy
on:
workflow_dispatch:
push:
branches: [ master ]
jobs:
upload_image:
runs-on: ubuntu-latest
outputs:
image_url: ${{ steps.pubish_image.outputs.image_url }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Publish Image
id: pubish_image
uses: ripplr-io/docr-docker-publish@v1
with:
image_path: ripplr/ripplr-api
- name: Remove Old Images
uses: ripplr-io/docr-image-remove@v1
with:
image_repository: ripplr-api
run_migrations:
runs-on: ubuntu-latest
needs: upload_image
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ripplr
- name: Run migration
run: kubectl create -f kube/jobs/migrate.yml
- name: Wait for job status
run: kubectl wait --for=condition=complete job/migrate
- name: Delete older migration jobs
run: kubectl delete job migrate
deploy:
runs-on: ubuntu-latest
needs:
- upload_image
- run_migrations
steps:
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_ACCESS_TOKEN }}
- name: Save DigitalOcean kubeconfig
run: doctl kubernetes cluster kubeconfig save ripplr
- name: Deploy
run: |
kubectl set image deployment/ripplr-api ripplr-api=${{ needs.upload_image.outputs.image_url }}
kubectl set image deployment/sidekiq sidekiq=${{ needs.upload_image.outputs.image_url }}
kubectl set image deployment/terminal terminal=${{ needs.upload_image.outputs.image_url }}
- name: Verify deployment
run: kubectl rollout status deployment/ripplr-api
slack_notifications_success:
if: success()
runs-on: ubuntu-latest
needs:
- upload_image
- run_migrations
- deploy
steps:
- name: Send slack notifications
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{secrets.SLACK_DEPLOY_WEBHOOK}}
name: 'API Deployed!'
icon_emoji: ':rocket:'
slack_notifications_failure:
if: failure()
runs-on: ubuntu-latest
needs:
- upload_image
- run_migrations
- deploy
steps:
- name: Send slack notifications
uses: Gamesight/slack-workflow-status@master
with:
repo_token: ${{ secrets.GITHUB_TOKEN }}
slack_webhook_url: ${{secrets.SLACK_DEPLOY_WEBHOOK}}
name: 'API Deployment Failed!'
icon_emoji: ':collision:'