-
Notifications
You must be signed in to change notification settings - Fork 1
116 lines (109 loc) · 4.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
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
name: Deploy Earth Observations API
on:
workflow_dispatch:
inputs:
stack:
description: The stack to be deployed. stable (default - currently the only option)
required: true
default: stable
env:
SWARM_HOSTNAME: ${{ secrets.SWARM_HOSTNAME }} # Organization secret
SWARM_USERNAME: ${{ secrets.SWARM_USERNAME }} # Organization secret
SWARM_PASSWORD: ${{ secrets.SWARM_PASSWORD }} # Organization secret
SWARM_SSH_PORT: ${{ secrets.SWARM_SSH_PORT }} # Organization secret
BRANCH_REF: main
REGISTRY: ghcr.io
jobs:
build-raster:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout source code
uses: actions/checkout@main
with:
ref: ${{ env.BRANCH_REF }}
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}_raster_${{ inputs.stack }}
tags: |
type=sha
- name: Build and push
uses: docker/build-push-action@master
with:
context: .
file: services/raster/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
build-stac:
runs-on: ubuntu-latest
outputs:
image: ${{ steps.meta.outputs.tags }}
steps:
- name: Checkout source code
uses: actions/checkout@main
with:
ref: ${{ env.BRANCH_REF }}
- name: Log in to the Container registry
uses: docker/login-action@master
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@master
with:
images: ${{ env.REGISTRY }}/${{ github.repository }}_stac_${{ inputs.stack }}
tags: |
type=sha
- name: Build and push
uses: docker/build-push-action@master
with:
context: .
file: services/stac/Dockerfile
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
deploy:
needs: [build-raster, build-stac]
runs-on: saeon
env:
STACK: ${{ inputs.stack }}
steps:
- uses: actions/checkout@main
with:
ref: ${{ env.BRANCH_REF }}
- name: (SCP) Copy Docker files to host
uses: appleboy/scp-action@master
with:
host: ${{ env.SWARM_HOSTNAME }}
username: ${{ env.SWARM_USERNAME }}
password: ${{ env.SWARM_PASSWORD }}
port: ${{ env.SWARM_SSH_PORT }}
source: deploy/${{ env.STACK }}/stack.yml
target: eoapi
- name: (SSH) Deploy Docker stack
uses: appleboy/ssh-action@master
with:
host: ${{ env.SWARM_HOSTNAME }}
username: ${{ env.SWARM_USERNAME }}
password: ${{ env.SWARM_PASSWORD }}
port: ${{ env.SWARM_SSH_PORT }}
script: |
echo "RASTER_IMAGE=${{ needs.build-raster.outputs.image }}" > /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
echo "STAC_IMAGE=${{ needs.build-stac.outputs.image }}" >> /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
echo "PG_USER=${{ secrets.PG_USER }}" >> /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
echo "PG_PASSWORD=${{ secrets.PG_PASSWORD }}" >> /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
echo "PG_HOST_STABLE=${{ secrets.PG_HOST_STABLE }}" >> /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
echo "PG_PORT_STABLE=${{ secrets.PG_PORT_STABLE }}" >> /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env
sudo /opt/deploy-docker-stack.sh /home/runner/eoapi/deploy/${{ env.STACK }}/stack.yml /home/runner/eoapi/deploy/${{ env.STACK }}/stack.env eoapi_${{ env.STACK }}