Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add terraform-deploy reusable workflow #59

Merged
merged 6 commits into from
Sep 12, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
57 changes: 57 additions & 0 deletions .github/workflows/terraform-apply.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
# Based on https://github.com/canonical/sunbeam-terraform/blob/9973905d24892903fab19ce691bbc5c28c53df0a/.github/workflows/deploy.yml
# For usage, refer to templates/terraform-deploy-usage-template.yaml
# Applies terraform module and wait for the application to go active or blocked.
name: Apply Terraform module

on:
workflow_call:
inputs:
model:
description: The model that the charm is deployed on. Defaults to `testing`.
required: false
type: string
default: testing
channel:
description: The channel that the charm is deployed from. Defaults to `latest/stable`.
required: false
type: string
default: latest/stable
module-directory:
description: The directory that stores the Terraform module. Defaults to `./terraform`.
required: false
type: string
default: ./terraform
DnPlas marked this conversation as resolved.
Show resolved Hide resolved

jobs:
apply:
name: Apply 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"
orfeas-k marked this conversation as resolved.
Show resolved Hide resolved
juju-channel: 3.4/stable
charmcraft-channel: latest/candidate
- name: Install dependencies
run: |
sudo snap install --classic terraform
- name: Create juju model
run: juju add-model ${{ inputs.model }}
- name: Apply terraform
working-directory: ${{ inputs.module-directory }}
run: |
terraform init
terraform apply -var "channel=${{ inputs.channel }}" -var "model_name=${{ inputs.model }}" --auto-approve
- name: Wait for the application to be active or blocked
run: |
juju wait-for model ${{ inputs.model }} --query='forEach(applications, app => (app.status == "active" || app.status == "blocked") )'
- name: Juju status
run: juju status
rgildein marked this conversation as resolved.
Show resolved Hide resolved
- name: Dump logs
if: failure()
uses: canonical/charming-actions/dump-logs@2.6.3
13 changes: 13 additions & 0 deletions examples/terraform-apply-usage-example.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
# trigger workflow
jobs:
terraform-apply:
name: Apply
uses: canonical/charmed-kubeflow-workflows/.github/workflows/terraform-deploy.yaml@main
with:
# Defaults to "testing"
model: kubeflow
# Defaults to "latest/stable" due to it being the default channel in most of our charms
channel: latest/edge
# Add the line below for multi-charm repos. For single-repo repositories, it can be
# omitted since the workflow was designed according to CC006 spec file structure conventions.
module-directory: charms/<charm-name>/terraform