Skip to content

Demo | Workflow 1 - Plan Targetted at Staging #18

Demo | Workflow 1 - Plan Targetted at Staging

Demo | Workflow 1 - Plan Targetted at Staging #18

name: Demo | Workflow 1 - Plan Targetted at Staging
on:
workflow_dispatch:
inputs:
environment:
description: "Target RTL Environment"
required: true
type: choice
options:
- sandbox
- staging
- production
pull_request:
types: [opened, reopened]
# Target
branches:
- main
# Only if .tf files in this directory are part of the diff.
paths:
- 'workload/terraform/jamfpro/*.tf'
jobs:
# Check changes are coming from a feat-* or bugfix-* named branch
check-branch-name:
uses: ./.github/workflows/branch_name_check.yml
with:
branch-name: ${{ github.ref_name }}
# Terraform Plan
terraform:
environment: ${{ github.event_name == 'workflow_dispatch' && github.event.inputs.environment || 'staging' }}
runs-on: ubuntu-latest
env:
TF_API_KEY: ${{ secrets.TF_API_KEY }}
TF_CLOUD_ORGANIZATION: ${{ vars.TF_CLOUD_ORG }}
# Bring repo to runner
steps:
- name: checkout
uses: actions/checkout@v4
- name: Upload Configuration
uses: hashicorp/tfc-workflows-github/actions/[email protected]
id: upload-config
with:
token: ${{ secrets.TF_API_KEY }}
workspace: ${{ vars.TF_WORKSPACE }}
directory: "workload/terraform/jamfpro"
speculative: true
# Run plan using hashi create-run
- name: Terraform Plan
id: terraform-plan
uses: hashicorp/tfc-workflows-github/actions/[email protected]
with:
token: ${{ secrets.TF_API_KEY }}
workspace: ${{ vars.TF_WORKSPACE }}
configuration_version: ${{ steps.upload-config.outputs.configuration_version_id }}