-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Added workflow for deploy review app and delete while closing pull re…
…quest
- Loading branch information
Venkata Challa
committed
Jan 2, 2024
1 parent
da68e26
commit 4f85a14
Showing
2 changed files
with
152 additions
and
0 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,43 @@ | ||
name: Delete review app on AKS | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- main | ||
types: | ||
- closed | ||
|
||
concurrency: deploy-${{ github.ref }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
environment: review | ||
|
||
steps: | ||
- name: Destroy review app | ||
uses: actions/checkout@v4 | ||
|
||
- 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: ${{ secrets.AZURE_CREDENTIALS }} | ||
|
||
- name: Terraform Destroy | ||
run: | | ||
make ci review terraform-destroy | ||
env: | ||
PR_NUMBER: ${{ github.event.pull_request.number }} | ||
|
||
- name: Post Pull Request Comment | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: aks | ||
message: | | ||
Review app track and pay deployed to <https://track-and-pay-${{ github.event.number }}.test.teacherservices.cloud> was deleted | ||
Review app school placements deployed to <https://manage-school-placements-${{ github.event.number }}.test.teacherservices.cloud> was deleted |
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,109 @@ | ||
name: Build and deploy to AKS cluster | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
|
||
concurrency: deploy-${{ github.ref }} | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
outputs: | ||
docker-image-tag: ${{ steps.build-image.outputs.tag }} | ||
matrix-environments: ${{ toJSON(steps.*.outputs.matrix-environment) }} | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
|
||
- name: Setup ruby | ||
uses: ruby/setup-ruby@v1 | ||
with: | ||
ruby-version: 3.2.2 | ||
bundler-cache: true | ||
- name: Use Node.js 20.9.0 | ||
uses: actions/setup-node@v4 | ||
with: | ||
node-version: 20.9.0 | ||
cache: "npm" | ||
- name: Install dependencies | ||
run: | | ||
sudo apt-get update && sudo apt-get -yqq install libpq-dev | ||
bundle install --jobs 4 --retry 3 | ||
bundle exec rails assets:precompile | ||
env: | ||
DATABASE_URL: postgres://postgres:password@localhost:5432 | ||
GOVUK_NOTIFY_API_KEY: fake_key | ||
SIGN_IN_METHOD: persona | ||
|
||
- name: Intellisense | ||
run: bin/bundle exec yard gems | ||
|
||
- name: Build and push docker image | ||
id: build-image | ||
uses: DFE-Digital/github-actions/build-docker-image@master | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
context: . | ||
env: | ||
SIGN_IN_METHOD: persona | ||
|
||
- name: Prepare matrix environments review | ||
id: matrix-env-review | ||
if: github.event_name == 'pull_request' | ||
run: echo "matrix-environment=review" >> $GITHUB_OUTPUT | ||
|
||
deploy: | ||
name: Deploy ${{ matrix.environment }} | ||
runs-on: ubuntu-latest | ||
needs: [build] | ||
environment: | ||
name: ${{ matrix.environment }} | ||
url: ${{ steps.get-app-url.outputs.url1 }} | ||
strategy: | ||
max-parallel: 1 | ||
matrix: | ||
environment: ${{ fromJSON(needs.build.outputs.matrix-environments) }} | ||
|
||
steps: | ||
- 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 | ||
with: | ||
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 | ||
- name: Post comment to Pull Request ${{ github.event.number }} | ||
if: ${{ github.event_name == 'pull_request' }} | ||
uses: marocchino/sticky-pull-request-comment@v2 | ||
with: | ||
header: aks | ||
message: | | ||
Review app track and pay deployed to <https://track-and-pay-${{ github.event.number }}.test.teacherservices.cloud> | ||
Review app school placements deployed to <https://manage-school-placements-${{ github.event.number }}.test.teacherservices.cloud> |