-
-
Notifications
You must be signed in to change notification settings - Fork 18
93 lines (79 loc) · 2.79 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
name: Deploy dim-api
on:
workflow_dispatch:
push:
branches:
- master
paths:
- '.github/workflows/deploy.yml'
- 'api/**'
- 'dim-gg-static/**'
- 'kubernetes/dim-api-deployment.yaml'
- 'kubernetes/deploy.sh'
- 'Dockerfile'
- '.babelrc'
- 'package.json'
- 'tsconfig.json'
jobs:
build:
runs-on: ubuntu-latest
environment: production
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 2 # So sentry can get the previous commit
- uses: pnpm/action-setup@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version-file: '.nvmrc'
cache: pnpm
- name: pnpm install
run: pnpm install --frozen-lockfile --prefer-offline
- name: Install doctl
uses: digitalocean/action-doctl@v2
with:
token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_PASSWORD }}
- name: Save DigitalOcean kubeconfig with short-lived credentials
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{secrets.K8S_CLUSTER}}
- name: Add IP address to trusted source (managed database)
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: 'add'
database_id: ${{ secrets.DATABASE_ID }}
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Run DB migrations
run: cd api && npx db-migrate up -e prod
env:
DATABASE_USER: ${{ secrets.DATABASE_USER }}
DATABASE_PASSWORD: ${{ secrets.DATABASE_PASSWORD }}
DATABASE_HOST: ${{ secrets.DATABASE_HOST }}
DATABASE_NAME: ${{ secrets.DATABASE_NAME }}
DATABASE_PORT: ${{ secrets.DATABASE_PORT }}
- name: Remove IP address to trusted source (managed database)
if: always()
continue-on-error: true
uses: GarreauArthur/manage-digital-ocean-managed-database-trusted-sources-gh-action@main
with:
action: 'remove'
database_id: ${{ secrets.DATABASE_ID }}
digitalocean_token: ${{ secrets.DIGITALOCEAN_TOKEN }}
- name: Build and deploy
run: pnpm run deploy
- name: Create Sentry release
uses: getsentry/action-release@v1
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: destiny-item-manager
SENTRY_PROJECT: dim-api
with:
environment: production
version: ${{ env.GITHUB_SHA }}
ignore_missing: true
- name: Verify deployment
run: kubectl rollout status deployment/dim-api