Skip to content

Commit

Permalink
Review comments fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Venkata Challa committed Jan 4, 2024
1 parent d3f2c7b commit bbe0d3b
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 25 deletions.
44 changes: 44 additions & 0 deletions .github/actions/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
name: Deploy environment
description: Deploys an application environment

inputs:
environment:
description: The name of the environment
required: true
docker-image:
description: The Docker image to deploy
required: true
azure-credentials:
description: JSON object containing a service principal that can read from Azure Key Vault
required: true
pull-request-number:
description: The pull request number which triggered this deploy.
required: true

runs:
using: composite

steps:
- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
terraform_wrapper: false

- uses: DFE-Digital/github-actions/set-arm-environment-variables@master
with:
azure-credentials: ${{ inputs.azure-credentials }}

- name: Terraform Apply
run: |
make ci ${{ inputs.environment }} terraform-apply
env:
DOCKER_IMAGE_TAG: ${{ inputs.docker-image }}
PR_NUMBER: ${{ inputs.pull-request-number }}

- name: Get application URL
id: get-app-url
run: |
url1="https://track-and-pay-${{ inputs.pull-request-number }}.test.teacherservices.cloud"
echo "url1=${url1}" >> $GITHUB_OUTPUT
url2="https://manage-school-placements-${{ inputs.pull-request-number }}.test.teacherservices.cloud"
echo "url2=${url2}" >> $GITHUB_OUTPUT
33 changes: 8 additions & 25 deletions .github/workflows/build_and_deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ concurrency: deploy-${{ github.ref }}
jobs:
build:
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
outputs:
docker-image-tag: ${{ steps.build-image.outputs.tag }}
matrix-environments: ${{ toJSON(steps.*.outputs.matrix-environment) }}
Expand Down Expand Up @@ -60,13 +59,13 @@ jobs:
if: github.event_name == 'pull_request'
run: echo "matrix-environment=review" >> $GITHUB_OUTPUT

deploy:
name: Deploy ${{ matrix.environment }}
deploy_review :
name: Deploy to review environment
runs-on: ubuntu-latest
if: ${{ contains(github.event.pull_request.labels.*.name, 'deploy') }}
needs: [build]
environment:
name: ${{ matrix.environment }}
name: review
url: ${{ steps.get-app-url.outputs.url1 }}
strategy:
max-parallel: 1
Expand All @@ -77,29 +76,13 @@ jobs:
- name: Checkout code
uses: actions/checkout@v3

- uses: hashicorp/setup-terraform@v3
with:
terraform_version: 1.6.4
terraform_wrapper: false

- uses: DFE-Digital/github-actions/set-arm-environment-variables@master
- uses: ./.github/actions/deploy-environment
id: deploy
with:
environment: review
docker-image: ${{ needs.build.outputs.docker-image-tag }}
azure-credentials: ${{ secrets.AZURE_CREDENTIALS }}

- name: Terraform Apply
run: |
make ci ${{ matrix.environment }} terraform-apply
env:
DOCKER_IMAGE_TAG: ${{ needs.build.outputs.docker-image-tag }}
PR_NUMBER: ${{ github.event.pull_request.number }}

- name: Get application URL
id: get-app-url
run: |
url1="https://track-and-pay-${{ github.event.number }}.test.teacherservices.cloud"
echo "url1=${url1}" >> $GITHUB_OUTPUT
url2="https://manage-school-placements-${{ github.event.number }}.test.teacherservices.cloud"
echo "url2=${url2}" >> $GITHUB_OUTPUT
pull-request-number: ${{ github.event.pull_request.number }}

- name: Post comment to Pull Request ${{ github.event.number }}
if: ${{ github.event_name == 'pull_request' }}
Expand Down

0 comments on commit bbe0d3b

Please sign in to comment.