-
Notifications
You must be signed in to change notification settings - Fork 0
99 lines (83 loc) · 3.18 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
name: deploy
on:
push:
branches:
- main
tags:
- 'v*'
env:
# We don't want to do certain steps if this is running in a fork
IS_ORIGINAL_REPO: ${{ github.repository == 'microbiomedata/nmdc-server' }}
# Used to determine if we add the special `prod` Docker image tag
IS_PROD_RELEASE: ${{ startsWith(github.ref, 'refs/tags/v') }}
jobs:
build:
runs-on: ubuntu-latest
strategy:
matrix:
image: [server, client, worker]
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# history for all branches and tags is needed for setuptools-scm
fetch-depth: 0
- name: Docker meta
id: meta
uses: docker/metadata-action@v5
with:
images: |
ghcr.io/microbiomedata/nmdc-server/${{ matrix.image }}
flavor: |
latest=false
tags: |
type=ref,event=branch
type=semver,pattern={{version}}
type=raw,value=prod,enable=${{ env.IS_PROD_RELEASE }}
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v5
with:
context: ${{ matrix.image == 'client' && 'web' || '.' }}
push: ${{ env.IS_ORIGINAL_REPO }}
file: ${{ matrix.image == 'worker' && 'Dockerfile.worker' || (matrix.image == 'client' && 'web/Dockerfile' || 'Dockerfile') }}
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
redeploy:
needs: build
runs-on: ubuntu-latest
env:
WORKLOAD_API_BASE: https://rancher2.spin.nersc.gov/v3/project/c-tmq7p:p-bkv45/workloads
strategy:
matrix:
deployment: [ backend, frontend, worker ]
steps:
- name: Redeploy nmdc-dev:portal-${{ matrix.deployment }}
if: ${{ env.IS_PROD_RELEASE == 'false' && env.IS_ORIGINAL_REPO == 'true' }}
uses: fjogeleit/http-request-action@v1
with:
url: ${{ env.WORKLOAD_API_BASE }}/deployment:nmdc-dev:portal-${{ matrix.deployment }}?action=redeploy
method: POST
username: ${{ secrets.SPIN_USER }}
password: ${{ secrets.SPIN_PASSWORD }}
- name: Redeploy nmdc:portal-${{ matrix.deployment }}
if: ${{ env.IS_PROD_RELEASE == 'true' && env.IS_ORIGINAL_REPO == 'true' }}
uses: fjogeleit/http-request-action@v1
with:
url: ${{ env.WORKLOAD_API_BASE }}/deployment:nmdc:portal-${{ matrix.deployment }}?action=redeploy
method: POST
username: ${{ secrets.SPIN_USER }}
password: ${{ secrets.SPIN_PASSWORD }}
- name: Redeploy nmdc-sandbox:${{ matrix.deployment }}
if: ${{ env.IS_PROD_RELEASE == 'true' && env.IS_ORIGINAL_REPO == 'true' }}
uses: fjogeleit/http-request-action@v1
with:
url: ${{ env.WORKLOAD_API_BASE }}/deployment:nmdc-sandbox:${{ matrix.deployment }}?action=redeploy
method: POST
username: ${{ secrets.SPIN_USER }}
password: ${{ secrets.SPIN_PASSWORD }}