New Relic Terraform deployment #21
Workflow file for this run
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: New Relic Terraform deployment | |
on: | |
workflow_dispatch: | |
inputs: | |
dryRun: | |
type: boolean | |
required: true | |
description: Flag to run terraform apply command. If yes, resources will be planned but won't applied. | |
default: false | |
destroy: | |
type: boolean | |
required: true | |
description: Flag to run terraform destroy command. If yes, resources will be destroyed. | |
default: false | |
stack: | |
type: choice | |
required: true | |
description: Stack type of the environment | |
options: | |
- infra | |
- apps | |
language: | |
type: choice | |
required: false | |
description: Programming language | |
default: "" | |
options: | |
- "" | |
- golang | |
jobs: | |
terraform_deploy: | |
name: "Deploy ${{ inputs.stack }}" | |
runs-on: ubuntu-latest | |
env: | |
ARM_TENANT_ID: ${{ secrets.AZURE_TENANT_ID }} | |
ARM_SUBSCRIPTION_ID: ${{ secrets.AZURE_SUBSCRIPTION_ID }} | |
ARM_CLIENT_ID: ${{ secrets.AZURE_SERVICE_PRINCIPAL_APP_ID }} | |
ARM_CLIENT_SECRET: ${{ secrets.AZURE_SERVICE_PRINCIPAL_SECRET }} | |
steps: | |
- name: Checkout repository | |
id: checkout_repo | |
uses: actions/checkout@v4 | |
- name: Install Terraform | |
id: install_terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Deploy Terraform ${{ inputs.stack }} | |
id: deploy_terraform | |
run: | | |
stack=${{ inputs.stack }} | |
if [[ ${stack} == 'infra' ]]; then | |
bash ./monitoring/newrelic/${stack}/deploy.sh \ | |
--project ${{ secrets.PROJECT }} \ | |
--instance ${{ secrets.INSTANCE }} \ | |
--cluster-type aks \ | |
--newrelic-opsteam-account-id ${{ secrets.NEWRELIC_ACCOUNT_ID_OPSTEAM }} \ | |
--newrelic-region ${{ secrets.NEWRELIC_REGION }} \ | |
--newrelic-user-api-key ${{ secrets.NEWRELIC_USER_API_KEY }} \ | |
--dry-run ${{ inputs.dryRun }} \ | |
--destroy ${{ inputs.destroy }} | |
elif [[ ${stack} == 'apps' ]]; then | |
bash ./monitoring/newrelic/${stack}/deploy.sh \ | |
--project ${{ secrets.PROJECT }} \ | |
--instance ${{ secrets.INSTANCE }} \ | |
--cluster-type aks \ | |
--newrelic-opsteam-account-id ${{ secrets.NEWRELIC_ACCOUNT_ID_OPSTEAM }} \ | |
--newrelic-region ${{ secrets.NEWRELIC_REGION }} \ | |
--newrelic-user-api-key ${{ secrets.NEWRELIC_USER_API_KEY }} \ | |
--language ${{ inputs.language }} \ | |
--dry-run ${{ inputs.dryRun }} \ | |
--destroy ${{ inputs.destroy }} | |
else | |
echo "Given stack is incorrect!" | |
exit 1 | |
fi |