This repository has been archived by the owner on Jun 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 6
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
20 additions
and
92 deletions.
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
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 |
---|---|---|
|
@@ -7,88 +7,35 @@ on: | |
branches: | ||
- master | ||
|
||
# Environment variables available to all jobs and steps in this workflow | ||
env: | ||
GKE_PROJECT_ID: ${{ secrets.GKE_PROJECT_ID }} | ||
GKE_EMAIL: ${{ secrets.GKE_EMAIL }} | ||
CLOUD_SQL_SERVICE_ACCOUNT: ${{ secrets.CLOUD_SQL_SERVICE_ACCOUNT }} | ||
CLOUD_STORE_SERVICE_ACCOUNT: ${{ secrets.CLOUD_STORE_SERVICE_ACCOUNT }} | ||
POSTGRES_PASSWORD: ${{ secrets.POSTGRES_PASSWORD }} | ||
GITHUB_SHA: ${{ github.sha }} | ||
GKE_ZONE: europe-west4-b | ||
GKE_CLUSTER: prod | ||
REGISTRY_HOSTNAME: eu.gcr.io | ||
|
||
jobs: | ||
setup-build-publish-deploy: | ||
name: Deploy | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v2 | ||
|
||
- name: Checkout | ||
uses: actions/checkout@v2 | ||
- name: Setup Node | ||
uses: actions/[email protected] | ||
with: | ||
node-version: '14' | ||
|
||
# begin caching | ||
- name: Get yarn cache directory path | ||
id: yarn-cache-dir-path | ||
- name: Get yarn cache | ||
id: yarn-cache | ||
run: echo "::set-output name=dir::$(yarn cache dir)" | ||
|
||
- uses: actions/cache@v2 | ||
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) | ||
- name: Cache dependencies | ||
uses: actions/cache@v2 | ||
with: | ||
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | ||
path: ${{ steps.yarn-cache.outputs.dir }} | ||
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-yarn- | ||
# end caching | ||
|
||
# Setup gcloud CLI | ||
- uses: GoogleCloudPlatform/github-actions/setup-gcloud@master | ||
with: | ||
version: '270.0.0' | ||
service_account_email: ${{ secrets.GKE_EMAIL }} | ||
service_account_key: ${{ secrets.GKE_KEY }} | ||
project_id: ${{ secrets.GKE_PROJECT_ID }} | ||
- uses: actions/[email protected] | ||
with: | ||
java-version: 1.11 | ||
|
||
# Configure docker to use the gcloud command-line tool as a credential helper | ||
- run: | | ||
# Set up docker to authenticate | ||
# via gcloud command-line tool. | ||
gcloud auth configure-docker | ||
# Build and push image to Google Container Registry | ||
- name: Build | ||
run: |- | ||
gradle jib | ||
# Deploy the Docker image to the GKE cluster | ||
- name: Prepare Helm | ||
uses: azure/setup-helm@v1 | ||
with: | ||
version: v3.1.2 | ||
- run: yarn install --frozen-lockfile | ||
- run: yarn build | ||
|
||
- name: Deploy | ||
run: | | ||
gcloud container clusters get-credentials "$GKE_CLUSTER" --zone "$GKE_ZONE" --project "$GKE_PROJECT_ID" | ||
echo -n "${CLOUD_SQL_SERVICE_ACCOUNT}" > chart/cloudsql.base64.json | ||
echo -n "${CLOUD_STORE_SERVICE_ACCOUNT}" > chart/cloudstore.base64.json | ||
helm repo add stable "https://kubernetes-charts.storage.googleapis.com" | ||
helm upgrade --install traefik stable/traefik -f chart/traefik.values.yaml | ||
values="" | ||
target="${GITHUB_REF//refs\/heads\//}" | ||
if [[ "$GITHUB_EVENT_NAME" == "release" ]]; then | ||
target="production" | ||
elif [[ -f "chart/values.${target}.yml" ]]; then | ||
values="-f chart/values.${target}.yml" | ||
else | ||
echo "unkown target ${target}" | ||
exit 42 | ||
fi | ||
helm upgrade --install "imis-${target}" chart $values \ | ||
--set gitSha=${GITHUB_SHA} --set "secrets.postgres=$(echo -n ${POSTGRES_PASSWORD} | base64)" | ||
kubectl rollout status "deployment/imis-${target}" | ||
uses: peaceiris/actions-gh-pages@v3 | ||
with: | ||
github_token: ${{ secrets.GITHUB_TOKEN }} | ||
publish_dir: ./dist |
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