-
Notifications
You must be signed in to change notification settings - Fork 1
52 lines (47 loc) · 2.08 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
name: Deploy MongoDB
on:
workflow_dispatch:
inputs:
stack:
description: The stack to be deployed. vNext (default) or v6
required: false
default: vNext
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
MONGO_INITDB_DATABASE: ${{ secrets.MONGO_INITDB_DATABASE }} # Repository secret
MONGO_INITDB_ROOT_USERNAME: ${{ secrets.MONGO_INITDB_ROOT_USERNAME }} # Repository secret
MONGO_INITDB_ROOT_PASSWORD: ${{ secrets.MONGO_INITDB_ROOT_PASSWORD }} # Repository secret
BRANCH_REF: main
jobs:
deploy:
runs-on: saeon
env:
STACK: ${{ inputs.stack }}
steps:
- uses: actions/checkout@master
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: "${{ env.STACK }}/stack.yml"
target: "mongo"
- 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 "MONGO_INITDB_DATABASE=${{ env.MONGO_INITDB_DATABASE }}" > /home/runner/mongo/${{ env.STACK }}/stack.env
echo "MONGO_INITDB_ROOT_USERNAME=${{ env.MONGO_INITDB_ROOT_USERNAME }}" >> /home/runner/mongo/${{ env.STACK }}/stack.env
echo "MONGO_INITDB_ROOT_PASSWORD=${{ env.MONGO_INITDB_ROOT_PASSWORD }}" >> /home/runner/mongo/${{ env.STACK }}/stack.env
sudo /opt/deploy-docker-stack.sh /home/runner/mongo/${{ env.STACK }}/stack.yml /home/runner/mongo/${{ env.STACK }}/stack.env mongo_${{ env.STACK }}