Skip to content

Commit

Permalink
feat: Add reusable workflow to deploy terraform module
Browse files Browse the repository at this point in the history
  • Loading branch information
orfeas-k committed Sep 9, 2024
1 parent 66ec46e commit 1982e2b
Showing 1 changed file with 62 additions and 0 deletions.
62 changes: 62 additions & 0 deletions .github/workflows/terraform-deploy.yaml
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

0 comments on commit 1982e2b

Please sign in to comment.