-
Notifications
You must be signed in to change notification settings - Fork 3
85 lines (71 loc) · 2.46 KB
/
terraform_test_deploy.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
name: Terraform deploy to a fresh microk8s model
on:
pull_request:
branches:
- '**'
paths:
- 'frontend/charm/**'
- 'backend/charm/**'
pull_request_review:
on:
pull_request_review:
types:
- submitted
paths:
- 'frontend/charm/**'
- 'backend/charm/**'
- 'terraform/**'
push:
branches: ["main"]
tags: ["v*.*.*"]
workflow_dispatch:
jobs:
deploy:
name: terraform deploy + upgrade charms
# if: github.event.review.state == 'APPROVED'
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
# TODO: Separate this build step to its own action once custom VM images are available
# (when there is a charmcraft + LXD capable image available)
- name: Build API charm
run: charmcraft pack
working-directory: ./backend/charm
# TODO: Separate this build step to its own action once custom VM images are available
# (when there is a charmcraft + LXD capable image available)
- 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: Switch model to test-observer-development
run: |
juju switch test-observer-development
- name: Replace the API charm with the locally built one
run: |
juju refresh api --path ../backend/charm/*.charm
- name: Replace the frontend charm with the locally built one
run: |
juju refresh frontend --path ../frontend/charm/*.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")'