removed building #34
Workflow file for this run
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
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: | |
if: github.event_name != 'workflow_dispatch' | |
uses: ./.github/workflows/branch_name_check.yml | |
with: | |
branch-name: ${{ github.event.pull_request.head.ref }} | |
# Terraform Plan | |
terraform-upload-and-plan: | |
needs: check-branch-name | |
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 }} | |
steps: | |
# Bring repo to runner | |
- name: checkout | |
uses: actions/checkout@v4 | |
# Upload the config to TF cloud | |
- 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 speculative 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 }} | |
plan_only: true | |
# Deposit run info to the runner in temporary .json file | |
- name: Save Run Info | |
run: | | |
cat << EOF > outputs.json | |
{ | |
"pr_ref": "${{ github.event.pull_request.number }}", | |
"status": "${{ steps.terraform-plan.outputs.status }}", | |
"run_id": "${{ steps.terraform-plan.outputs.run_id }}", | |
"run_status": "${{ steps.terraform-plan.outputs.run_status }}", | |
"run_message": "${{ steps.terraform-plan.outputs.run_message }}", | |
"run_link": "${{ steps.terraform-plan.outputs.run_link }}", | |
"plan_id": "${{ steps.terraform-plan.outputs.plan_id }}", | |
"plan_status": "${{ steps.terraform-plan.outputs.plan_status }}", | |
"configuration_version_id": "${{ steps.terraform-plan.outputs.configuration_version_id }}" | |
} | |
EOF | |
- name: Upload outputs as Artifact | |
uses: actions/upload-artifact@v4 | |
with: | |
name: output-test | |
path: outputs.json | |
retention-days: 0 | |
update-pr: | |
name: Update PR | |
needs: terraform-upload-and-plan | |
uses: ./.github/workflows/run_python_script.yml | |
with: | |
outputs-payload: output-test | |
# TO DO | |
# Call amended python script to pickup the file and despoit it as a comment on the PR which triggered this workflow | |
# Check if the "status" == "success". If yes, exit success, else exit failure. | |