Merge pull request #20 from pingidentity/PDI-2142-readme #50
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: Feature Deploy Push | |
on: | |
push: | |
jobs: | |
fmt: | |
runs-on: ubuntu-latest | |
env: | |
TERRAFORM_ENV_BASE64: ${{ secrets.TERRAFORM_ENV_BASE64 }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: fmt-check | |
run: | | |
terraform fmt -recursive -check . | |
lint: | |
needs: [fmt] | |
runs-on: ubuntu-latest | |
env: | |
TERRAFORM_ENV_BASE64: ${{ secrets.TERRAFORM_ENV_BASE64 }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: terraform-linters/setup-tflint@v4 | |
name: Setup TFLint | |
with: | |
tflint_version: latest | |
- name: tflint | |
run: | | |
echo "***Running terraform lint***" | |
tflint --recursive | |
validate: | |
needs: [lint] | |
name: validate | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
env: | |
TERRAFORM_ENV_BASE64: ${{ secrets.TERRAFORM_ENV_BASE64 }} | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
- run: |- | |
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars | |
source tfvars | |
_tfdir=terraform | |
_branch=$(echo "${GITHUB_REF}" | sed -e "s#refs/heads/##g") | |
export TF_VAR_pingone_environment_name=${_branch} | |
case $_branch in | |
prod) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate" | |
;; | |
qa) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate" | |
;; | |
*) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/dev/${_branch}/terraform.tfstate" | |
;; | |
esac | |
terraform -chdir=${_tfdir} init \ | |
-backend-config="bucket=$TF_VAR_tf_state_bucket" \ | |
-backend-config="region=$TF_VAR_tf_state_region" \ | |
-backend-config="key=${_stateKey}" | |
echo "***Running terraform validate***" | |
terraform -chdir=${_tfdir} validate | |
deploy: | |
if: ${{ !contains(github.event.commits[0].message, '[skip ci]')}} | |
name: Deploy | |
needs: [validate] | |
runs-on: ubuntu-latest | |
timeout-minutes: 5 | |
env: | |
TERRAFORM_ENV_BASE64: ${{ secrets.TERRAFORM_ENV_BASE64 }} | |
steps: | |
- name: Check out code into the Go module directory | |
uses: actions/checkout@v4 | |
- uses: hashicorp/setup-terraform@v3 | |
- run: |- | |
echo $TERRAFORM_ENV_BASE64 | base64 -d > tfvars | |
source tfvars | |
_tfdir=terraform | |
_branch=$(echo "${GITHUB_REF}" | sed -e "s#refs/heads/##g") | |
export TF_VAR_pingone_environment_name=${_branch} | |
case $_branch in | |
prod) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/prod/terraform.tfstate" | |
;; | |
qa) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/qa/terraform.tfstate" | |
;; | |
*) | |
_stateKey="${TF_VAR_tf_state_key_prefix}/dev/${_branch}/terraform.tfstate" | |
;; | |
esac | |
terraform -chdir=${_tfdir} init \ | |
-backend-config="bucket=$TF_VAR_tf_state_bucket" \ | |
-backend-config="region=$TF_VAR_tf_state_region" \ | |
-backend-config="key=${_stateKey}" | |
echo "***Running terraform apply***" | |
terraform -chdir=${_tfdir} apply --auto-approve |