-
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.
feat: Add reusable workflow to deploy terraform module
- Loading branch information
Showing
1 changed file
with
62 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,62 @@ | ||
name: Deploy Terraform module | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
working-directory: | ||
description: The directory that stores the Terraform module. | ||
required: false | ||
type: string | ||
default: ./terraform | ||
model: | ||
description: The model that the charm is deployed on. | ||
required: false | ||
type: string | ||
default: kubeflow | ||
channel: | ||
description: The channel that the charm is deployed from. | ||
required: false | ||
type: string | ||
default: latest/edge | ||
workload-check: | ||
description: If true, pass `-w` as an argument to juju-wait. This means it will wait for the unit to go to active. It defaults to false since most of kubeflow charms have other depenndencies required in order for them to be active. | ||
required: false | ||
type: boolean | ||
default: false | ||
|
||
jobs: | ||
deploy: | ||
name: Deploy Terraform | ||
runs-on: ubuntu-20.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v3 | ||
- name: Setup operator environment | ||
uses: charmed-kubernetes/actions-operator@main | ||
with: | ||
provider: microk8s | ||
channel: 1.29-strict/stable | ||
microk8s-addons: "dns storage rbac metallb:10.64.140.43-10.64.140.49" | ||
juju-channel: 3.4/stable | ||
charmcraft-channel: latest/candidate | ||
- name: Install dependencies | ||
run: | | ||
sudo snap install --classic terraform | ||
sudo snap install --classic juju-wait | ||
- name: Apply terraform | ||
run: | | ||
# echo '{"credential": "microk8s", "enable-vault": true, "enable-barbican": true, "enable-designate": true, "nameservers": "testing.github."}' > terraform.tfvars.json | ||
cd ${{ inputs.working-directory }} | ||
terraform init | ||
terraform apply -var "channel=${{ inputs.channel }}" -var "model_name=${{ inputs.model }}" --auto-approve | ||
if [ "${{ inputs.workload-check }}" = false ]; then | ||
juju-wait -v -m ${{ inputs.model }} -t 3600 | ||
else | ||
juju-wait -vw -m ${{ inputs.model }} -t 3600 | ||
fi | ||
- name: Collect juju status | ||
if: always() | ||
run: | | ||
juju status -m ${{ inputs.model }} | ||
juju debug-log -m ${{ inputs.model }} --replay |