Skip to content

Run Test

Run Test #79

Workflow file for this run

name: 'Run Test'
on:
workflow_dispatch:
inputs:
use_modules_from_terraform_registry:
type: boolean
required: false
env:
TF_CLI_ARGS: "-no-color"
TF_INPUT: 0
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
permissions:
contents: read
jobs:
terraform:
strategy:
fail-fast: false
matrix:
include:
- name: DSF POC - SONAR
workspace: dsf_cli-sonar-
enable_sonar: true
enable_dam: false
enable_dra: false
name: '${{ matrix.name }}'
runs-on: ubuntu-latest
env:
EXAMPLE_DIR: ./examples/aws/poc/dsf_deployment
AWS_REGION: eu-west-2
TF_VAR_enable_sonar: ${{ matrix.enable_sonar }}
TF_VAR_enable_dam: ${{ matrix.enable_dam }}
TF_VAR_enable_dra: ${{ matrix.enable_dra }}
TF_VAR_allowed_ssh_cidrs: "[\"82.0.0.0/8\", \"62.0.0.0/8\", \"94.0.0.0/8\"]"
environment: test
# Use the Bash shell regardless whether the GitHub Actions runner is ubuntu-latest, macos-latest, or windows-latest
defaults:
run:
shell: bash
steps:
- name: Pick ref
run: |
if [ -z "${{ inputs.explicit_ref }}" ]; then
echo REF=${{ github.ref }} >> $GITHUB_ENV;
else
echo REF=${{ inputs.explicit_ref }} >> $GITHUB_ENV;
fi
- name: Set Workspace Name
run: |
echo TF_WORKSPACE=dsf_cli-sonar-schedule-master >> $GITHUB_ENV
# Checkout the repository to the GitHub Actions runner
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.REF }}
- name: Change the modules source to local
if: ${{ inputs.use_modules_from_terraform_registry == false }}
run: |
find ./examples/ -type f -exec sed -i -f sed.expr {} \;
- name: Create terraform backend file
run: |
cat << EOF > $EXAMPLE_DIR/backend.tf
terraform {
backend "s3" {
bucket = "terraform-state-bucket-dsfkit-github-tests"
key = "states/terraform.tfstate"
dynamodb_table = "terraform-state-lock"
region = "us-east-1"
}
}
EOF
# Install the latest version of Terraform CLI and configure the Terraform CLI configuration file with a Terraform Cloud user API token
- name: Setup Terraform
uses: hashicorp/setup-terraform@v2
with:
terraform_wrapper: false
terraform_version: ~1.7.0
- name: Setup jq
uses: sergeysova/jq-action@v2
- name: Create License File
env:
MY_SECRET: ${{ secrets.DAM_LICENSE }}
run: |
echo "${{ secrets.DAM_LICENSE }}" | base64 -d > $EXAMPLE_DIR/license.mprv
cat $EXAMPLE_DIR/license.mprv
# Initialize a new or existing Terraform working directory by creating initial files, loading any remote state, downloading modules, etc.
- name: Terraform Init
run: terraform -chdir=$EXAMPLE_DIR init
env:
TF_WORKSPACE: default
- name: Terraform Output
if: always()
run: terraform -chdir=$EXAMPLE_DIR output -json
- name: Collect Artifacts
if: always()
uses: actions/upload-artifact@v2
with:
name: collected-keys
path: |
${{ env.EXAMPLE_DIR }}/ssh_keys
- name: Terraform Destroy
id: destroy
if: always()
run: |
terraform -chdir=$EXAMPLE_DIR destroy -var dam_license=license.mprv -auto-approve