Skip to content

Commit

Permalink
init
Browse files Browse the repository at this point in the history
  • Loading branch information
ictorn committed Aug 25, 2022
0 parents commit 5ff99e7
Showing 1 changed file with 69 additions and 0 deletions.
69 changes: 69 additions & 0 deletions action.yml
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

0 comments on commit 5ff99e7

Please sign in to comment.