Skip to content

Commit

Permalink
Merge branch 'main' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
dedenbangkit committed Jan 8, 2024
2 parents 02d7301 + ce5f53d commit efd7578
Show file tree
Hide file tree
Showing 6 changed files with 160 additions and 89 deletions.
14 changes: 14 additions & 0 deletions .github/actions/install-google-cloud-sdk/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: 'Install GKE Auth Plugin Action'
description: 'Install GKE Auth Plugin Action'
runs:
using: "composite"
steps:
- run: |
REPO_URL="https://packages.cloud.google.com/apt"
# Install the Google Cloud SDK
echo "deb [signed-by=/usr/share/keyrings/cloud.google.gpg] $REPO_URL cloud-sdk main" | sudo tee /etc/apt/sources.list.d/google-cloud-sdk.list
sudo curl https://packages.cloud.google.com/apt/doc/apt-key.gpg | sudo apt-key --keyring /usr/share/keyrings/cloud.google.gpg add -
sudo apt-get update -y
sudo apt-get install -y google-cloud-sdk-gke-gcloud-auth-plugin
shell: bash
141 changes: 141 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
name: RTMIS CI

on:
push:
branch:
"*"
pull_request:
types: [synchronize]

jobs:
build_pull_request_action:
if: github.event_name == 'pull_request' && github.event.action == 'synchronize'
name: RTMIS pipeline for pull request
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install GKE auth plugin
uses: ./.github/actions/install-google-cloud-sdk

- name: Set short git commit SHA
id: vars
run: |
shortSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$shortSha" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create credentials folder
run: mkdir /home/runner/work/rtmis/credentials
shell: bash

- name: Write gcp deployment secret to file
run: echo "${{ secrets.GCLOUD_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/gcp.json
shell: bash

- name: Write gcp deployment secret to file
run: echo "${{ secrets.RTMIS_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/rtmis-service-account.json
shell: bash

- name: Build and test
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ${{ github.ref_name }}
CI_TAG: ${{ github.ref_name }}
CI_PULL_REQUEST: true
CI_COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
shell: bash
run: |
./ci/build.sh
- name: Deploy
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ${{ github.ref_name }}
CI_TAG: ${{ github.ref_name }}
CI_PULL_REQUEST: true
CI_COMMIT_RANGE: ${{ github.event.pull_request.base.sha }}..${{ github.event.pull_request.head.sha }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
shell: bash
run: |
./ci/deploy.sh
build_push_action:
if: github.event_name == 'push' && !contains(github.event.before, '0000000000000000000000000000000000000000')
name: RTMIS pipeline for push action
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v1

- name: Install GKE auth plugin
uses: ./.github/actions/install-google-cloud-sdk

- name: Set short git commit SHA
id: vars
run: |
shortSha=$(git rev-parse --short ${{ github.sha }})
echo "COMMIT_SHORT_SHA=$shortSha" >> $GITHUB_ENV
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create credentials folder
run: mkdir /home/runner/work/rtmis/credentials
shell: bash

- name: Write gcp deployment secret to file
run: echo "${{ secrets.GCLOUD_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/gcp.json
shell: bash

- name: Write gcp deployment secret to file
run: echo "${{ secrets.RTMIS_SERVICE_ACCOUNT }}" | base64 --decode > /home/runner/work/rtmis/credentials/rtmis-service-account.json
shell: bash

- name: Build and test
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ${{ github.ref_name }}
CI_TAG: ""
CI_PULL_REQUEST: false
CI_COMMIT_RANGE: ${{ github.event.before }}..${{ github.sha }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
DBDOCS_TOKEN: ${{ secrets.DBDOCS_TOKEN }}
shell: bash
run: |
./ci/build.sh
- name: Deploy
env:
CI_COMMIT: ${{ env.COMMIT_SHORT_SHA }}
CI_BRANCH: ${{ github.ref_name }}
CI_TAG: ""
CI_PULL_REQUEST: false
CI_COMMIT_RANGE: ${{ github.event.before }}..${{ github.sha }}
CLOUDSDK_CORE_DISABLE_PROMPTS: 1
COMPOSE_INTERACTIVE_NO_CLI: 1
COVERALLS_REPO_TOKEN: ${{ secrets.COVERALLS_RTMIS_TOKEN }}
SERVICE_ACCOUNT: "/home/runner/work/rtmis/credentials"
shell: bash
run: |
./ci/deploy.sh
63 changes: 0 additions & 63 deletions .semaphore/semaphore.yml

This file was deleted.

26 changes: 2 additions & 24 deletions ci/build.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,6 @@ set -exuo pipefail
[[ "${CI_BRANCH}" == "gh-pages" ]] && { echo "GH Pages update. Skip all"; exit 0; }
[[ -n "${CI_TAG:=}" ]] && { echo "Skip build"; exit 0; }

## RESTORE IMAGE CACHE
IMAGE_CACHE_LIST=$(grep image ./docker-compose.yml \
| sort -u | sed 's/image\://g' \
| sed 's/^ *//g')
mkdir -p ./ci/images

while IFS= read -r IMAGE_CACHE; do
IMAGE_CACHE_LOC="./ci/images/${IMAGE_CACHE//\//-}.tar"
if [ -f "${IMAGE_CACHE_LOC}" ]; then
docker load -i "${IMAGE_CACHE_LOC}"
fi
done <<< "${IMAGE_CACHE_LIST}"

if grep -q .yml .gitignore; then
echo "ERROR: .gitignore contains other docker-compose file"
exit 1
Expand Down Expand Up @@ -68,7 +55,7 @@ dci () {
}

documentation_build() {
docker run -it --rm -v "$(pwd)/docs:/docs" \
docker run -i --rm -v "$(pwd)/docs:/docs" \
akvo/akvo-sphinx:20220525.082728.594558b make html
cp -r docs/build/html frontend/public/documentation
}
Expand Down Expand Up @@ -146,13 +133,4 @@ if [[ ${FRONTEND_CHANGES} == 1 && ${BACKEND_CHANGES} == 1 ]]; then
echo "Build failed when running basic.sh"
exit 1
fi
fi

## STORE IMAGE CACHE
while IFS= read -r IMAGE_CACHE; do
IMAGE_CACHE_LOC="./ci/images/${IMAGE_CACHE//\//-}.tar"
if [[ ! -f "${IMAGE_CACHE_LOC}" ]]; then
docker save -o "${IMAGE_CACHE_LOC}" "${IMAGE_CACHE}"
fi
done <<< "${IMAGE_CACHE_LIST}"
## END STORE IMAGE CACHE
fi
3 changes: 1 addition & 2 deletions ci/deploy.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ set -exuo pipefail
[[ "${CI_PULL_REQUEST}" == "true" ]] && { echo "Pull request. Skip deploy"; exit 0; }

auth () {
gcloud auth activate-service-account --key-file=/home/semaphore/.secrets/gcp.json
gcloud auth activate-service-account --key-file=/home/runner/work/rtmis/credentials/gcp.json
gcloud config set project akvo-lumen
gcloud config set container/cluster europe-west1-d
gcloud config set compute/zone europe-west1-d
Expand Down Expand Up @@ -49,4 +49,3 @@ prepare_deployment
apply_deployment

ci/k8s/wait-for-k8s-deployment-to-be-ready.sh

Original file line number Diff line number Diff line change
Expand Up @@ -917,6 +917,7 @@ exports[`Login and Registration test if the registration form exists: Registrati
id="registration-form_password"
placeholder="Password"
type="password"
value=""
/>
<span
class="ant-input-suffix"
Expand Down Expand Up @@ -986,6 +987,7 @@ exports[`Login and Registration test if the registration form exists: Registrati
id="registration-form_confirm"
placeholder="Confirm Password"
type="password"
value=""
/>
<span
class="ant-input-suffix"
Expand Down

0 comments on commit efd7578

Please sign in to comment.