pokeapi/.github/workflows/kustomize.yml

51 lines
2 KiB
YAML
Raw Normal View History

2021-05-28 15:06:06 +00:00
name: Deploy Kustomize k8s cluster
2021-05-27 17:25:40 +00:00
on:
workflow_run:
workflows: ["Build and Push Docker image"]
branches: [master, staging]
types:
- completed
2021-05-30 21:21:40 +00:00
schedule:
2021-06-01 13:17:54 +00:00
- cron: '0 0 1 * *'
2021-05-27 17:25:40 +00:00
jobs:
2021-05-28 15:06:06 +00:00
create-kustomize-cluster:
2021-05-27 17:25:40 +00:00
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
2021-05-27 17:25:40 +00:00
steps:
- name: Checkout
uses: actions/checkout@v2
with:
submodules: recursive
2021-06-01 13:17:54 +00:00
- name: Lint
run: (cd Resources/k8s/kustomize && yamllint .)
2021-05-27 17:25:40 +00:00
- name: Create k8s Kind Cluster
uses: helm/kind-action@v1.1.0
2021-05-28 09:53:23 +00:00
with:
version: v0.11.1
- name: Create deployment configuration
run: |
cp Resources/k8s/kustomize/base/secrets/postgres.env.sample Resources/k8s/kustomize/base/secrets/postgres.env
cp Resources/k8s/kustomize/base/secrets/graphql.env.sample Resources/k8s/kustomize/base/secrets/graphql.env
cp Resources/k8s/kustomize/base/config/pokeapi.env.sample Resources/k8s/kustomize/base/config/pokeapi.env
2021-05-28 15:06:06 +00:00
- name: K8s Apply
2021-05-27 17:25:40 +00:00
run: |
if [ ${GITHUB_REF#refs/heads/} = 'master' ]; then make kustomize-apply; else make kustomize-staging-apply; fi
2021-05-28 15:06:06 +00:00
kubectl proxy &
kubectl describe deployment
2021-05-28 15:06:06 +00:00
bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/
2021-05-28 15:11:59 +00:00
- name: Set default namespace
run: |
kubectl config set-context --current --namespace pokeapi
2021-05-28 15:06:06 +00:00
- name: Migrate and build data
run: |
2021-05-27 18:38:25 +00:00
make k8s-migrate
make k8s-build-db
2021-05-28 15:06:06 +00:00
bash Resources/scripts/wait.sh http://localhost:8001/api/v1/namespaces/pokeapi/services/pokeapi/proxy/api/v2/pal-park-area/5/
- name: K8s Apply
run: |
kubectl wait --timeout=120s --for=condition=complete job/load-graphql
last_command=$(kubectl get job -o jsonpath='{.status.succeeded}' load-graphql)
2021-06-01 12:37:49 +00:00
test "$last_command" -eq 1