GitHub workflow for validating terraform deploy
+ upgrading charms
#18
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
name: Terraform deploy to a fresh microk8s model | |
on: | |
push: | |
branches: ["*"] | |
tags: | |
- "v*.*.*" | |
pull_request: | |
branches: | |
- '**' | |
paths: | |
- 'frontend/charm/**' | |
- 'backend/charm/**' | |
# pull_request_review: | |
# on: | |
# pull_request_review: | |
# types: | |
# - submitted | |
# paths: | |
# - 'frontend/charm/**' | |
# - 'backend/charm/**' | |
# - 'terraform/**' | |
workflow_dispatch: | |
jobs: | |
deploy: | |
runs-on: [self-hosted, jammy, xlarge] | |
defaults: | |
run: | |
working-directory: ./terraform | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Terraform dependencies | |
run: | | |
sudo apt-get update | |
sudo apt-get install unzip | |
- name: Set up terraform | |
uses: hashicorp/setup-terraform@v1 | |
- name: Terraform init | |
run: terraform init | |
- name: Set up microk8s | |
uses: canonical/certification-github-workflows/.github/actions/microk8s-setup@main | |
- name: Build API charm | |
run: charmcraft pack | |
working-directory: ./backend/charm | |
- name: Build frontend charm | |
run: charmcraft pack | |
working-directory: ./frontend/charm | |
- name: Terraform apply | |
run: | | |
TF_VAR_environment=development \ | |
TF_VAR_nginx_ingress_integrator_charm_whitelist_source_range="" \ | |
terraform apply -auto-approve | |
- name: Replace the API charm with the locally built one | |
run: | | |
juju refresh api --path ../backend/charm/test-observer-api_ubuntu-22.04-amd64.charm | |
- name: Wait for deployment to complete | |
run: | | |
juju wait-for model test-observer-development \ | |
--timeout=10m \ | |
--query='life=="alive" && status=="available" && forEach(applications, app => app.status == "active")' |