-
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.
- Loading branch information
0 parents
commit 5ff99e7
Showing
1 changed file
with
69 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
name: 'deploy app' | ||
description: 'deploy application to the DOKS cluster' | ||
inputs: | ||
sha: | ||
description: 'commit SHA' | ||
required: true | ||
environment: | ||
description: 'environment name' | ||
required: true | ||
namespace: | ||
description: 'k8s namespace' | ||
required: true | ||
deployment: | ||
description: 'deployment name' | ||
required: true | ||
migrations: | ||
description: 'migration job name' | ||
required: true | ||
do-access-token: | ||
description: 'DO access token' | ||
required: true | ||
cluster: | ||
description: 'DOKS cluster name or ID' | ||
required: true | ||
version: | ||
description: 'kubectl version tag' | ||
required: false | ||
default: 'latest' | ||
runs: | ||
using: "composite" | ||
steps: | ||
- uses: digitalocean/action-doctl@v2 | ||
with: | ||
token: ${{ inputs.do-access-token }} | ||
- name: pull image with kubectl binary | ||
run: docker pull ghcr.io/medius-pro/kubectl | ||
shell: bash | ||
- name: create temporary container | ||
run: docker create --name kubectl ghcr.io/medius-pro/kubectl /medius-kubectl | ||
shell: bash | ||
- name: copy binary | ||
run: docker cp kubectl:/medius-kubectl /usr/local/bin/doks | ||
shell: bash | ||
- name: set cluster config context | ||
run: doctl kubernetes cluster kubeconfig save --expiry-seconds 600 ${{ inputs.cluster }} | ||
shell: bash | ||
- name: apply deployment | ||
env: | ||
COMMIT_SHA: ${{ inputs.sha }} | ||
run: envsubst < .github/k8s/${{ inputs.environment }}.yaml | doks apply -f - | ||
shell: bash | ||
- name: wait for deployment to complete | ||
run: doks -n ${{ inputs.namespace }} rollout status deployment/${{ inputs.deployment }} | ||
shell: bash | ||
- name: wait for migrations job to complete | ||
run: doks -n ${{ inputs.namespace }} wait --for=condition=Complete --timeout=30s job "${{ inputs.migrations }}" -o=jsonpath='{.status.conditions[*].type}' | grep -q Complete || exit 1 | ||
id: migrations | ||
continue-on-error: true | ||
shell: bash | ||
- name: get logs from migrations job | ||
if: ${{ success() }} | ||
run: doks -n ${{ inputs.namespace }} logs $(doks -n ${{ inputs.namespace }} get pod -l controller-uid=$(doks -n ${{ inputs.namespace }} get job "${{ inputs.migrations }}" -o "jsonpath={.metadata.labels.controller-uid}") -o name) | ||
shell: bash | ||
- name: throw an error if migrations job failed | ||
if: ${{ failure() && steps.migrations.conclusion == 'failure' }} | ||
run: | | ||
echo "database migration error" | ||
exit 1 | ||
shell: bash |