forked from akvo/rtmis
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request akvo#1536 from akvo/feature/1533-self-host
[akvo#1533] Add production composite actions and and simplify frontend build
- Loading branch information
Showing
7 changed files
with
130 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Docker Compose Build and Restart | ||
|
||
inputs: | ||
server-ip: | ||
description: 'Server IP address' | ||
required: true | ||
server-ssh-port: | ||
description: 'Server SSH port' | ||
required: true | ||
server-ssh-secret-key: | ||
description: 'The SSH secret key from server' | ||
required: true | ||
server-ssh-user: | ||
description: 'SSH User' | ||
required: true | ||
docker-compose-file: | ||
description: 'Docker compose file location' | ||
required: true | ||
docker-compose-file-frontend-build: | ||
description: 'Docker compose for frontend build file location' | ||
required: true | ||
ci_commit: | ||
description: 'Commit ID' | ||
required: true | ||
|
||
runs: | ||
using: "composite" | ||
steps: | ||
- name: Write secret to file | ||
run: echo "${{ inputs.server-ssh-secret-key }}" > priv.key && chmod 600 priv.key | ||
shell: bash | ||
|
||
- name: Git Pull | ||
run: .github/composite-actions/ssh-docker-compose/git-pull.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} | ||
shell: bash | ||
|
||
- name: Rebuild Frontend | ||
run: .github/composite-actions/ssh-docker-compose/frontend-build.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} ${{ inputs.docker-compose-file-frontend-build }} ${{ inputs.ci_commit }} | ||
shell: bash | ||
|
||
- name: Rebuild | ||
run: .github/composite-actions/ssh-docker-compose/build.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} ${{ inputs.docker-compose-file }} ${{ inputs.ci_commit }} | ||
shell: bash | ||
|
||
- name: Up | ||
run: .github/composite-actions/ssh-docker-compose/up.sh ${{ inputs.server-ip }} ${{ inputs.server-ssh-port }} ${{ inputs.server-ssh-user }} ${{ inputs.docker-compose-file }} | ||
shell: bash |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
# ${1} for Server IP | ||
# ${2} for Server Port | ||
# ${3} for Server User | ||
# ${4} for Dockerfile location | ||
|
||
server_ip="${1}" | ||
server_port="${2}" | ||
server_user="${3}" | ||
docker_compose_file="${4}" | ||
ci_commit="${5}" | ||
|
||
ssh -i priv.key -o BatchMode=yes \ | ||
-p "${server_port}" \ | ||
-o UserKnownHostsFile=/dev/null \ | ||
-o StrictHostKeyChecking=no \ | ||
"${server_user}"@"${server_ip}" "cd src/deploy && CI_COMMIT=${ci_commit} docker compose -f ${docker_compose_file} build --no-cache" |
19 changes: 19 additions & 0 deletions
19
.github/composite-actions/ssh-docker-compose/frontend-build.sh
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
# ${1} for Server IP | ||
# ${2} for Server Port | ||
# ${3} for Server User | ||
# ${4} for Dockerfile location | ||
|
||
server_ip="${1}" | ||
server_port="${2}" | ||
server_user="${3}" | ||
docker_compose_file="${4}" | ||
ci_commit="${5}" | ||
|
||
ssh -i priv.key -o BatchMode=yes \ | ||
-p "${server_port}" \ | ||
-o UserKnownHostsFile=/dev/null \ | ||
-o StrictHostKeyChecking=no \ | ||
"${server_user}"@"${server_ip}" "cd src/deploy && CI_COMMIT=${ci_commit} docker compose -f ${docker_compose_file} up --build" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
# ${1} for Server IP | ||
# ${2} for Server Port | ||
# ${3} for Server User | ||
|
||
server_ip="${1}" | ||
server_port="${2}" | ||
server_user="${3}" | ||
|
||
|
||
ssh -i priv.key -o BatchMode=yes \ | ||
-p "${server_port}" \ | ||
-o UserKnownHostsFile=/dev/null \ | ||
-o StrictHostKeyChecking=no \ | ||
"${server_user}"@"${server_ip}" "cd src/ && git pull" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#!/bin/bash | ||
set -eu | ||
|
||
# ${1} for Server IP | ||
# ${2} for Server Port | ||
# ${3} for Server User | ||
# ${4} for Dockerfile location | ||
|
||
server_ip="${1}" | ||
server_port="${2}" | ||
server_user="${3}" | ||
docker_compose_file="${4}" | ||
|
||
ssh -i priv.key -o BatchMode=yes \ | ||
-p "${server_port}" \ | ||
-o UserKnownHostsFile=/dev/null \ | ||
-o StrictHostKeyChecking=no \ | ||
"${server_user}"@"${server_ip}" "cd src/deploy && docker compose -f ${docker_compose_file} stop && docker compose -f ${docker_compose_file} up -d" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
#!/usr/bin/env bash | ||
#shellcheck disable=SC2039 | ||
|
||
set -euo pipefail | ||
|
||
yarn install --no-progress --frozen-lock | ||
yarn eslint --config .eslintrc.prod.json src --ext .js,.jsx | ||
yarn prettier --check src/ | ||
yarn build |