Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Optionally delay destroy in github actions to allow investigation #407

Merged
merged 70 commits into from
May 1, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
70 commits
Select commit Hold shift + click to select a range
47fbcd8
Optionally delay destroy in github actions to allow investigation
Apr 25, 2024
9d21860
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
3dd72a9
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
776b2e6
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
1401d44
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
ead4473
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
167d02b
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
249d074
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
4b9f710
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
937c165
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
6306ce0
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
303f508
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
4fc622b
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
ef38c7c
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
af8bace
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
415e466
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c7e7b24
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
35ad769
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
917548b
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
d56be18
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c2af605
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c1a04e4
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
aa50c1f
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
f1dbb8c
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
96b1f23
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
58f22c9
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
8fbbe95
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
61d1c1a
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
9c6bf2a
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
672632e
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
48af4d5
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
5575165
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
474da2d
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
cd03136
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
6fe0bbc
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
7d2fe33
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
7bdf735
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
43d20ba
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
4fb7a9f
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
ae1de47
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
a19ac2d
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
a1548d8
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
53a3acd
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
1a0f619
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
23a7e09
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
ac47e0c
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
636c0d2
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
0d0a9f6
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
01eaa72
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c89d6d4
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
34afb22
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
e911a57
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c26e773
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
629afd9
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
9df595a
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
b631bde
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
c1339ad
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
3d02362
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
3681b57
Optionally delay destroy in github actions to allow investigation time
Apr 25, 2024
3a849ae
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
7085c54
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
dd203c3
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
eeecfd5
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
d89dc53
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
2d7fb89
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
bccbbd7
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
ebf7439
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
7cf4029
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
eec180c
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
f3114ce
Optionally delay destroy in github actions to allow investigation time
Apr 28, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 32 additions & 12 deletions .github/workflows/dsf_poc_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
explicit_ref:
required: true
type: string
delay_destroy:
description: 'Delay the destroy step and subsequent steps to allow investigation'
type: boolean
default: false
required: true
secrets:
AWS_ACCESS_KEY_ID:
required: true
Expand Down Expand Up @@ -55,6 +60,7 @@ env:
TF_INPUT: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DESTROY_DELAY_SECONDS: 1800

permissions:
contents: read
Expand Down Expand Up @@ -211,13 +217,37 @@ jobs:
run: terraform -chdir=$EXAMPLE_DIR output -json

- name: Collect Artifacts
id: collect-artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: collected-keys
name: collected-keys-${{ env.TF_WORKSPACE }}
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# This step allows time for investigation of the failed resources before destroying them
- name: Conditional Delay
if: ${{ failure() }}
run: |
echo "delay_destroy: ${{ inputs.delay_destroy }}"
if [ "${{ inputs.delay_destroy }}" == "true" ]; then
echo "Terraform workspace: $TF_WORKSPACE"
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*${{ github.workflow }} ${{ env.TF_WORKSPACE }} automation Failed*\n You have ${{ env.DESTROY_DELAY_SECONDS }} seconds to investigate the environment before it is destroyed :alarm_clock:\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
echo ""
echo "Sleeping for $((DESTROY_DELAY_SECONDS / 60)) minutes before destroying the environment"
sleep $DESTROY_DELAY_SECONDS
fi

- name: Terraform Destroy
id: destroy
if: always()
Expand All @@ -235,16 +265,6 @@ jobs:
env:
TF_WORKSPACE: default

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# Send job failure to Slack
- name: Send Slack When Failure
run: |
Expand Down
45 changes: 33 additions & 12 deletions .github/workflows/dsf_poc_cli_azure.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
explicit_ref:
required: true
type: string
delay_destroy:
description: 'Delay the destroy step and subsequent steps to allow investigation'
type: boolean
default: false
required: true

secrets:
AWS_ACCESS_KEY_ID:
required: true
Expand Down Expand Up @@ -55,6 +61,7 @@ env:
ARM_CLIENT_ID: ${{ vars.ARM_CLIENT_ID }}
ARM_TENANT_ID: ${{ vars.ARM_TENANT_ID }}
ARM_CLIENT_SECRET: ${{ secrets.ARM_CLIENT_SECRET }}
DESTROY_DELAY_SECONDS: 1800
permissions:
contents: read

Expand Down Expand Up @@ -237,13 +244,37 @@ jobs:
run: terraform -chdir=$EXAMPLE_DIR output -json

- name: Collect Artifacts
id: collect-artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: collected-keys
name: collected-keys-${{ env.TF_WORKSPACE }}
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# This step allows time for investigation of the failed resources before destroying them
- name: Conditional Delay
if: ${{ failure() }}
run: |
echo "delay_destroy: ${{ inputs.delay_destroy }}"
if [ "${{ inputs.delay_destroy }}" == "true" ]; then
echo "Terraform workspace: $TF_WORKSPACE"
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*${{ github.workflow }} ${{ env.TF_WORKSPACE }} automation Failed*\n You have ${{ env.DESTROY_DELAY_SECONDS }} seconds to investigate the environment before it is destroyed :alarm_clock:\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
echo ""
echo "Sleeping for $((DESTROY_DELAY_SECONDS / 60)) minutes before destroying the environment"
sleep $DESTROY_DELAY_SECONDS
fi

- name: Terraform Destroy
id: destroy
if: always()
Expand All @@ -261,16 +292,6 @@ jobs:
env:
TF_WORKSPACE: default

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# Send job failure to Slack
- name: Send Slack When Failure
run: |
Expand Down
46 changes: 33 additions & 13 deletions .github/workflows/dsf_single_account_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
branch:
required: true
type: string
delay_destroy:
description: 'Delay the destroy step and subsequent steps to allow investigation'
type: boolean
default: false
required: true

workflow_call:
inputs:
Expand Down Expand Up @@ -73,7 +78,8 @@ env:
AWS_ACCESS_KEY_ID_STAGE: ${{ secrets.AWS_ACCESS_KEY_ID_STAGE }}
AWS_SECRET_ACCESS_KEY_STAGE: ${{ secrets.AWS_SECRET_ACCESS_KEY_STAGE }}
JUMP_SERVER_KEY: ${{ secrets.JUMP_SERVER_KEY }}
AWS_KEY_PATH: "aws_key.cer"
AWS_KEY_PATH: "jump_server_key.cer"
DESTROY_DELAY_SECONDS: 1800

permissions:
contents: read
Expand Down Expand Up @@ -213,13 +219,37 @@ jobs:
run: terraform -chdir=$EXAMPLE_DIR output -json

- name: Collect Artifacts
id: collect-artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: collected-keys
name: collected-keys-${{ env.TF_WORKSPACE }}
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# This step allows time for investigation of the failed resources before destroying them
- name: Conditional Delay
if: ${{ failure() }}
run: |
echo "delay_destroy: ${{ inputs.delay_destroy }}"
if [ "${{ inputs.delay_destroy }}" == "true" ]; then
echo "Terraform workspace: $TF_WORKSPACE"
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*${{ github.workflow }} ${{ env.TF_WORKSPACE }} automation Failed*\n You have ${{ env.DESTROY_DELAY_SECONDS }} seconds to investigate the environment before it is destroyed :alarm_clock:\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
echo ""
echo "Sleeping for $((DESTROY_DELAY_SECONDS / 60)) minutes before destroying the environment"
sleep $DESTROY_DELAY_SECONDS
fi

- name: Terraform Destroy
if: always()
run: terraform -chdir=$EXAMPLE_DIR destroy -auto-approve
Expand All @@ -243,16 +273,6 @@ jobs:
run: |
aws ec2 revoke-security-group-ingress --group-id ${{ vars.SYDNEY_SG_ID }} --security-group-rule-ids ${{ env.sg_id_for_sydney }}

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# Send job failure to Slack
- name: Send Slack When Failure
run: |
Expand Down
45 changes: 32 additions & 13 deletions .github/workflows/sonar_multi_account_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ on:
branch:
required: true
type: string
delay_destroy:
description: 'Delay the destroy step and subsequent steps to allow investigation'
type: boolean
default: false
required: true

workflow_call:
inputs:
Expand Down Expand Up @@ -39,7 +44,8 @@ env:
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
TF_WORKSPACE: "multi_account"
JUMP_SERVER_KEY: ${{ secrets.JUMP_SERVER_KEY }}
AWS_KEY_PATH: "aws_key.cer"
AWS_KEY_PATH: "jump_server_key.cer"
DESTROY_DELAY_SECONDS: 1800

permissions:
contents: read
Expand Down Expand Up @@ -154,6 +160,29 @@ jobs:
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# This step allows time for investigation of the failed resources before destroying them
- name: Conditional Delay
if: ${{ failure() }}
run: |
echo "delay_destroy: ${{ inputs.delay_destroy }}"
if [ "${{ inputs.delay_destroy }}" == "true" ]; then
echo "Terraform workspace: $TF_WORKSPACE"
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*${{ github.workflow }} ${{ env.TF_WORKSPACE }} automation Failed*\n You have ${{ env.DESTROY_DELAY_SECONDS }} seconds to investigate the environment before it is destroyed :alarm_clock:\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
echo ""
echo "Sleeping for $((DESTROY_DELAY_SECONDS / 60)) minutes before destroying the environment"
sleep $DESTROY_DELAY_SECONDS
fi

- name: Terraform Destroy
if: always()
run: terraform -chdir=$EXAMPLE_DIR destroy -auto-approve
Expand All @@ -166,22 +195,12 @@ jobs:
if: always()
run: aws ec2 revoke-security-group-ingress --group-id ${{ vars.JUMP_SERVER_SG_ID }} --security-group-rule-ids ${{ env.sg_id }}

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# Send job failure to Slack
- name: Send Slack When Failure
run: |
if [ ${{ inputs.branch }} == 'master' ]; then
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*Multi Account Prod ${{ inputs.workspace }} automation Failed*\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#dsfkit-prod"}' ${{ secrets.SLACK_WEBHOOK_URL }}
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*Sonar Multi Account Prod ${{ inputs.workspace }} automation Failed*\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#dsfkit-prod"}' ${{ secrets.SLACK_WEBHOOK_URL }}
else
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*Multi Account Dev nightly ${{ inputs.workspace }} automation Failed*\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*Sonar Multi Account Dev nightly ${{ inputs.workspace }} automation Failed*\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
fi
if: ${{ failure() }}
43 changes: 38 additions & 5 deletions .github/workflows/sonar_poc_cli.yml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,12 @@ on:
explicit_ref:
required: true
type: string
delay_destroy:
description: 'Delay the destroy step and subsequent steps to allow investigation'
type: boolean
default: false
required: true

secrets:
AWS_ACCESS_KEY_ID:
required: true
Expand Down Expand Up @@ -49,6 +55,7 @@ env:
TF_VAR_allowed_ssh_cidrs: "[\"82.0.0.0/8\", \"62.0.0.0/8\", \"94.0.0.0/8\"]"
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
DESTROY_DELAY_SECONDS: 1800

permissions:
contents: read
Expand All @@ -59,12 +66,14 @@ jobs:
fail-fast: false
matrix:
include:
- workspace: basic_cli-${{ github.run_number }}-${{ github.run_attempt }}
- name: Sonar Basic CLI
workspace: sonar_basic_cli-${{ github.run_number }}-${{ github.run_attempt }}
example_dir: ./examples/aws/poc/sonar_basic_deployment
aws_region: eu-west-2
hub_output: '.dsf_hub.value.public_dns'
gw_output: '.dsf_agentless_gw.value."agentless-gw-0".private_ip'
- workspace: hadr_cli-${{ github.run_number }}-${{ github.run_attempt }}
- name: Sonar HADR CLI
workspace: sonar_hadr_cli-${{ github.run_number }}-${{ github.run_attempt }}
example_dir: ./examples/aws/poc/sonar_hadr_deployment
aws_region: eu-west-1
hub_output: '.dsf_hubs.value.main.public_dns'
Expand Down Expand Up @@ -156,10 +165,11 @@ jobs:
run: terraform -chdir=$EXAMPLE_DIR output -json

- name: Collect Artifacts
id: collect-artifacts
if: always()
uses: actions/upload-artifact@v2
uses: actions/upload-artifact@v4
with:
name: collected-keys
name: collected-keys-${{ env.TF_WORKSPACE }}
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys

Expand All @@ -183,6 +193,29 @@ jobs:
port: 22
script: ip addr | grep -Eo 'inet (addr:)?([0-9]*\.){3}[0-9]*' | grep -Eo '([0-9]*\.){3}[0-9]*' | grep -v '127.0.0.1'

- name: Check how was the workflow run
id: check-trigger
if: ${{ failure() }}
run: |
if [ "${{ github.event_name }}" == "schedule" ]; then
echo "run-by=Automation" >> $GITHUB_OUTPUT
else
echo "run-by=${{ github.actor }}" >> $GITHUB_OUTPUT
fi

# This step allows time for investigation of the failed resources before destroying them
- name: Conditional Delay
if: ${{ failure() }}
run: |
echo "delay_destroy: ${{ inputs.delay_destroy }}"
if [ "${{ inputs.delay_destroy }}" == "true" ]; then
echo "Terraform workspace: $TF_WORKSPACE"
curl -X POST -H 'Content-type: application/json' --data '{"text":":exclamation: :exclamation: :exclamation:\n*${{ github.workflow }} ${{ env.TF_WORKSPACE }} automation Failed*\n You have ${{ env.DESTROY_DELAY_SECONDS }} seconds to investigate the environment before it is destroyed :alarm_clock:\n<https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}|Please check the job!>\nRun by: ${{ steps.check-trigger.outputs.run-by }}", "channel": "#edsf_automation"}' ${{ secrets.SLACK_WEBHOOK_URL }}
echo ""
echo "Sleeping for $((DESTROY_DELAY_SECONDS / 60)) minutes before destroying the environment"
sleep $DESTROY_DELAY_SECONDS
fi

- name: Terraform Destroy
id: destroy
if: always()
Expand All @@ -206,4 +239,4 @@ jobs:
fields: author,action,eventName,ref,workflow,pullRequest
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: ${{ failure() }}
if: ${{ failure() }}
Loading
Loading