feat/add subdomain privacy #23
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: TF -- Linode - Ops DNS | |
on: | |
pull_request: | |
branches: | |
- main | |
paths: | |
- 'terraform/ops-dns/**' | |
push: | |
branches: | |
- main | |
paths: | |
- 'terraform/ops-dns/**' | |
env: | |
TF_CLOUD_ORGANIZATION: freecodecamp | |
TF_API_TOKEN: ${{ secrets.TF_API_TOKEN }} | |
TF_WORKSPACE: tfws-ops-dns | |
CONFIG_DIRECTORY: terraform/ops-dns | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
jobs: | |
terraform-cloud-speculative-run: | |
if: github.event_name == 'pull_request' | |
runs-on: ubuntu-latest | |
name: Terraform Cloud Speculative Run | |
permissions: | |
contents: read | |
pull-requests: write | |
steps: | |
- name: Checkout | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 | |
# This is only for the GitHub Actions runner, not Terraform Cloud | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@633666f66e0061ca3b725c73b2ec20cd13a8fdd1 # v2 | |
# This is only for formatting check on GitHub Actions runner, not Terraform Cloud | |
- name: Terraform Format | |
id: fmt | |
run: terraform fmt -check -recursive -diff | |
- name: Post Format | |
if: | |
always() && github.ref != 'refs/heads/main' && (steps.fmt.outcome == | |
'success' || steps.fmt.outcome == 'failure') | |
uses: GetTerminus/terraform-pr-commenter@86bff5a07ff7586127ad776f0ba1faceb4d5c4ab # v2 | |
with: | |
commenter_type: fmt | |
commenter_input: | |
${{ format('{0}{1}', steps.fmt.outputs.stdout, | |
steps.fmt.outputs.stderr) }} | |
commenter_exitcode: ${{ steps.fmt.outputs.exitcode }} | |
# This is the minimum version required to get the comment to show up | |
terraform_version: 1.4 | |
- name: Terraform Cloud Upload Configuration | |
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: upload | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
directory: ${{ env.CONFIG_DIRECTORY }} | |
speculative: true | |
- name: Terraform Cloud Create Speculative Run | |
uses: hashicorp/tfc-workflows-github/actions/create-run@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: run | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
configuration_version: | |
${{ steps.upload.outputs.configuration_version_id }} | |
plan_only: true | |
message: 'Triggered From GitHub Actions CI ${{ github.sha }}' | |
- name: Terraform Cloud Plan Output | |
uses: hashicorp/tfc-workflows-github/actions/plan-output@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: plan-output | |
with: | |
plan: ${{ steps.run.outputs.plan_id }} | |
- name: Find Comment | |
uses: peter-evans/find-comment@a54c31d7fa095754bfef525c0c8e5e5674c4b4b1 # v2 | |
id: fc | |
with: | |
issue-number: ${{ github.event.pull_request.number }} | |
comment-author: 'github-actions[bot]' | |
body-includes: Run Details - ${{ env.TF_WORKSPACE }} | |
- name: Create or update comment | |
uses: peter-evans/create-or-update-comment@c6c9a1a66007646a28c153e2a8580a5bad27bcfa # v3 | |
with: | |
comment-id: ${{ steps.fc.outputs.comment-id }} | |
issue-number: ${{ github.event.pull_request.number }} | |
edit-mode: replace | |
body: | | |
Run Details - ${{ env.TF_WORKSPACE }} | |
**Terraform Cloud Plan Output** | |
``` | |
Plan: ${{ steps.plan-output.outputs.add }} to add, ${{ steps.plan-output.outputs.change }} to change, ${{ steps.plan-output.outputs.destroy }} to destroy. | |
``` | |
**TFC Run Link : <${{ steps.run.outputs.run_link }}>** | |
###### :red_circle: **Attention:** Merging these changes to the default branch WILL trigger a Terraform Cloud run to APPLY these changes, automatically. | |
terraform-cloud-apply-run: | |
if: github.ref == 'refs/heads/main' && github.event_name == 'push' | |
name: Terraform Cloud Apply Run | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
steps: | |
- name: Checkout | |
uses: actions/checkout@c85c95e3d7251135ab7dc9ce3241c5835cc595a9 # v3 | |
- name: Terraform Cloud Upload Configuration | |
uses: hashicorp/tfc-workflows-github/actions/upload-configuration@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: upload | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
directory: ${{ env.CONFIG_DIRECTORY }} | |
- name: Terraform Cloud Create Run | |
uses: hashicorp/tfc-workflows-github/actions/create-run@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: run | |
with: | |
workspace: ${{ env.TF_WORKSPACE }} | |
configuration_version: | |
${{ steps.upload.outputs.configuration_version_id }} | |
message: 'Triggered From GitHub Actions CI ${{ github.sha }}' | |
- uses: hashicorp/tfc-workflows-github/actions/apply-run@02ae73d5f2ff0b7eaec858cd12c41b3d914e8d2c # v1.0.2 | |
id: apply | |
if: | |
${{ | |
fromJSON(steps.run.outputs.payload).data.attributes.actions.IsConfirmable | |
}} | |
with: | |
run: ${{ steps.run.outputs.run_id }} | |
comment: 'Apply Run from GitHub Actions CI ${{ github.sha }}' |