Skip to content

Commit

Permalink
debug
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasmellos committed Jan 4, 2024
1 parent 627ea35 commit 87096c7
Showing 1 changed file with 30 additions and 59 deletions.
89 changes: 30 additions & 59 deletions .github/workflows/iac.yml
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,6 @@ on:
default: ''
description: GCP Service Account
secrets:
PRIVATE_SSH_KEY_TFMODULES:
required: true
AWS_ACCESS_KEY_ID:
required: true
AWS_ACCESS_KEY_SECRET:
Expand Down Expand Up @@ -84,9 +82,6 @@ on:
VAULT_TOKEN:
required: false
description: A Vault token in case vault is required
KNOWN_HOSTS:
required: false
description: SSH known hosts
PAT_GIT:
required: false
description: A PAT token to clone the repository
Expand All @@ -111,29 +106,6 @@ jobs:
ref: main
path: actions

# - uses: javbit/ssh-agent@jav/home
# with:
# ssh-private-key: ${{ secrets.PRIVATE_SSH_KEY_TFMODULES }}

# - name: Set up SSH
# run: |
# mkdir -p /home/runner/.ssh
# ssh-keyscan -H github.com >> $HOME/.ssh/known_hosts
# echo "${{ secrets.PRIVATE_SSH_KEY_TFMODULES }}" > $HOME/.ssh/github_actions
# chmod 600 /home/runner/.ssh/github_actions
# ssh-agent -a $SSH_AUTH_SOCK > /dev/null
# ssh-add /home/runner/.ssh/github_actions
# git config --global core.sshCommand "ssh -F $HOME/.ssh/github_actions"
# env:
# PRIVATE_SSH_KEY_TFMODULES: ${{ secrets.PRIVATE_SSH_KEY_TFMODULES }}
# SSH_AUTH_SOCK: /tmp/ssh_agent.sock
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.PRIVATE_SSH_KEY_TFMODULES }}
known_hosts: ${{ secrets.KNOWN_HOSTS }}
# - run: git clone [email protected]:signalwire/terraform-modules.git

- name: Configure AWS Credentials
uses: aws-actions/[email protected]
with:
Expand Down Expand Up @@ -176,7 +148,9 @@ jobs:
VAULT_TOKEN: ${{ secrets.VAULT_TOKEN }}

- uses: opentofu/setup-opentofu@v1
- name: Plan

- name: Init
id: init
uses: gruntwork-io/[email protected]
with:
tf_version: 1.5.7
Expand All @@ -190,27 +164,26 @@ jobs:
# print git configuration
INPUT_PRE_EXEC_2: |
git config --global --list
# - name: run terragrunt
# uses: autero1/[email protected]
# with:
# terragrunt_version: ${{ inputs.tg_version }}

# - name: Terragrunt init
# id: init
# working-directory: ${{ inputs.WORKING_DIR }}
# run: terragrunt run-all init --terragrunt-non-interactive
- name: Terragrunt validate
id: validate
run: terragrunt run-all validate --terragrunt-non-interactive
working-directory: ${{ inputs.WORKING_DIR }}
- name: Validate
uses: gruntwork-io/[email protected]
id: valdiate
with:
tf_version: 1.5.7
tg_version: 0.53.2
tg_dir: ${{ inputs.WORKING_DIR }}
tg_command: 'run-all validate'
env:
OVH_CLOUD_PROJECT_SERVICE: ${{ secrets.OVH_CLOUD_PROJECT_SERVICE }}

- name: Terragrunt plan

- name: Plan
uses: gruntwork-io/[email protected]
id: plan
run: terragrunt run-all plan -no-color --terragrunt-non-interactive > plan.txt
working-directory: ${{ inputs.WORKING_DIR }}
with:
tf_version: 1.5.7
tg_version: 0.53.2
tg_dir: ${{ inputs.WORKING_DIR }}
tg_command: 'run-all plan'
env:
TF_VAR_do_token: ${{ secrets.TF_VAR_DO_TOKEN }}
OS_AUTH_URL: https://auth.cloud.ovh.net/v3
Expand All @@ -227,34 +200,27 @@ jobs:
OVH_CONSUMER_KEY: ${{ secrets.OVH_CONSUMER_KEY }}
OVH_CLOUD_PROJECT_SERVICE: ${{ secrets.OVH_CLOUD_PROJECT_SERVICE }}

- name: Load plan file
id: read
uses: juliangruber/read-file-action@v1
with:
path: ${{ inputs.WORKING_DIR }}/plan.txt

- name: Terraform Plan Status
if: steps.plan.outcome == 'failure'
run: exit 1

- name: Update Pull Request
uses: actions/github-script@v7
if: github.event_name == 'pull_request'
env:
PLANPRINT: "terraform\n${{ steps.read.outputs.content }}"
# env:
# PLANPRINT: "terraform\n${{ steps.plan.outputs.content }}"
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const output = `### Refers to \`${{ inputs.WORKING_DIR }}\`
#### Terraform Format and Style 🖌\`${{ steps.fmt.outcome }}\`
#### Terraform Initialization ⚙️\`${{ steps.init.outcome }}\`
#### Terraform Plan 📖\`${{ steps.plan.outcome }}\`
#### Terraform Validation 🤖\`${{ steps.validate.outcome }}\`
<details><summary>Show Plan</summary>
\`\`\`\n
${process.env.PLANPRINT}
${{ steps.plan.outputs.tg_action_output }}
\`\`\`
</details>
Expand Down Expand Up @@ -286,10 +252,15 @@ jobs:
minimum-approvals: 1
issue-title: "Terragrunt approval pending for ${{ inputs.WORKING_DIR }}"

- name: Terragrunt apply-all
- name: Apply
if: github.ref == 'refs/heads/main' && github.event_name == 'push'
run: terragrunt apply-all --terragrunt-non-interactive
working-directory: ${{ inputs.WORKING_DIR }}
uses: gruntwork-io/[email protected]
id: apply
with:
tf_version: 1.5.7
tg_version: 0.53.2
tg_dir: ${{ inputs.WORKING_DIR }}
tg_command: 'run-all apply'
env:
TF_VAR_do_token: ${{ secrets.TF_VAR_DO_TOKEN }}
OS_AUTH_URL: https://auth.cloud.ovh.net/v3
Expand Down

0 comments on commit 87096c7

Please sign in to comment.