-
Notifications
You must be signed in to change notification settings - Fork 42
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Destroy environment workflow (#1146)
Co-authored-by: Oren Zohar <85433724+oren-zohar@users.noreply.github.com>
- Loading branch information
1 parent
e171e1f
commit 7ca2442
Showing
3 changed files
with
161 additions
and
34 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,54 @@ | ||
name: Destroy Environment | ||
run-name: Destroying ${{ github.event.inputs.prefix }}* by @${{ github.actor }} | ||
|
||
on: | ||
# Ability to execute on demand | ||
workflow_dispatch: | ||
inputs: | ||
ec-api-key: | ||
type: string | ||
description: "Elastic Cloud API key" | ||
required: true | ||
prefix: | ||
type: string | ||
description: "Delete all environments starting with `prefix`" | ||
required: true | ||
ignore-prefix: | ||
type: string | ||
description: "Ignore all environments starting with `ignore-prefix`" | ||
|
||
env: | ||
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | ||
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | ||
AWS_REGION: "eu-west-1" | ||
ENV_PREFIX: ${{ github.event.inputs.prefix }} | ||
ENV_IGNORE_PREFIX: ${{ github.event.inputs.ingore-prefix }} | ||
|
||
jobs: | ||
Destroy: | ||
runs-on: ubuntu-20.04 | ||
timeout-minutes: 120 | ||
steps: | ||
- name: Check out the repo | ||
uses: actions/checkout@v3 | ||
|
||
- name: Init Hermit | ||
run: ./bin/hermit env -r >> $GITHUB_ENV | ||
working-directory: ./ | ||
|
||
- name: Mask API Key | ||
run: | | ||
ec_api_key=$(jq -r '.inputs["ec-api-key"]' $GITHUB_EVENT_PATH) | ||
echo "::add-mask::$ec_api_key" | ||
echo "TF_VAR_ec_api_key=$ec_api_key" >> $GITHUB_ENV | ||
- name: Configure AWS credentials | ||
uses: aws-actions/configure-aws-credentials@v1-node16 | ||
with: | ||
aws-access-key-id: ${{ env.AWS_ACCESS_KEY_ID }} | ||
aws-secret-access-key: ${{ env.AWS_SECRET_ACCESS_KEY }} | ||
aws-region: ${{ env.AWS_REGION }} | ||
|
||
- name: Destroy Environment | ||
run: | | ||
just delete-cloud-env ${{ env.ENV_PREFIX }} '${{ env.ENV_IGNORE_PREFIX }}' "false" |
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
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