🔄 Terraform changes from feat-checks #109
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: "02 - terraform apply to: sandbox" | |
on: | |
pull_request: | |
types: | |
- closed | |
branches: | |
- 'sandbox' | |
env: | |
TF_CLOUD_ORGANIZATION: "deploymenttheory" | |
TF_API_TOKEN: "${{ secrets.TF_API_TOKEN }}" | |
TF_WORKSPACE: "terraform-jamfpro-sandbox" | |
CONFIG_DIRECTORY: "workload/terraform/jamfpro" | |
PIPELINE_DEBUG: true | |
permissions: | |
pull-requests: write # required to update PR | |
contents: write # required to create release and branch | |
id-token: write | |
jobs: | |
terraform-apply: | |
if: github.event.pull_request.merged == true | |
uses: ./.github/workflows/terraform-apply.yml | |
with: | |
tf_cloud_organization: "deploymenttheory" | |
tf_workspace: "terraform-jamfpro-sandbox" | |
config_directory: "workload/terraform/jamfpro" | |
debug: true | |
secrets: | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
update-pr: | |
needs: terraform-apply | |
if: github.event.pull_request.merged == true | |
runs-on: ubuntu-latest | |
steps: | |
- name: Update PR | |
uses: actions/github-script@v7 | |
with: | |
github-token: ${{ secrets.GITHUB_TOKEN }} | |
script: | | |
const applyResults = { | |
run_id: '${{ needs.terraform-apply.outputs.run_id }}', | |
apply_status: '${{ needs.terraform-apply.outputs.apply_status }}', | |
configuration_version: '${{ needs.terraform-apply.outputs.configuration_version }}', | |
workspace_id: '${{ needs.terraform-apply.outputs.workspace_id }}', | |
created_at: '${{ needs.terraform-apply.outputs.created_at }}', | |
status: '${{ needs.terraform-apply.outputs.status }}', | |
is_confirmable: '${{ needs.terraform-apply.outputs.is_confirmable }}', | |
is_cancelable: '${{ needs.terraform-apply.outputs.is_cancelable }}', | |
plan_only: '${{ needs.terraform-apply.outputs.plan_only }}', | |
has_changes: '${{ needs.terraform-apply.outputs.has_changes }}', | |
terraform_version: '${{ needs.terraform-apply.outputs.terraform_version }}', | |
source: '${{ needs.terraform-apply.outputs.source }}', | |
trigger_reason: '${{ needs.terraform-apply.outputs.trigger_reason }}' | |
}; | |
let output = `#### Terraform Apply Result 🚀\n\n`; | |
output += `**Status:** ${applyResults.status}\n\n`; | |
output += `**Run ID:** ${applyResults.run_id}\n`; | |
output += `**Apply Status:** ${applyResults.apply_status}\n`; | |
output += `**Configuration Version:** ${applyResults.configuration_version}\n`; | |
output += `**Workspace ID:** ${applyResults.workspace_id}\n`; | |
output += `**Created At:** ${applyResults.created_at}\n`; | |
output += `**Is Confirmable:** ${applyResults.is_confirmable}\n`; | |
output += `**Is Cancelable:** ${applyResults.is_cancelable}\n`; | |
output += `**Plan Only:** ${applyResults.plan_only}\n`; | |
output += `**Has Changes:** ${applyResults.has_changes}\n`; | |
output += `**Terraform Version:** ${applyResults.terraform_version}\n`; | |
output += `**Source:** ${applyResults.source}\n`; | |
output += `**Trigger Reason:** ${applyResults.trigger_reason}\n\n`; | |
output += `[View Run Details](https://app.terraform.io/app/${{ env.TF_CLOUD_ORGANIZATION }}/workspaces/${{ env.TF_WORKSPACE }}/runs/${applyResults.run_id})\n\n`; | |
output += `*Pushed by: @${{ github.actor }}, Action: \`${{ github.event_name }}\`*`; | |
await github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: output | |
}); |