Skip to content

Commit

Permalink
Added workflow to deploy review
Browse files Browse the repository at this point in the history
  • Loading branch information
Venkata Challa committed Dec 21, 2023
1 parent 750bf0c commit 81d3965
Show file tree
Hide file tree
Showing 2 changed files with 104 additions and 16 deletions.
88 changes: 88 additions & 0 deletions .github/workflows/deploy_aks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,88 @@
name: Build and deploy to AKS cluster

on:
push:
branches:
- master
pull_request:
branches:
- master

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: 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: .

- 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.url }}
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 plan
run: |
make ci ${{ matrix.environment }} terraform-plan
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: |
url=$(terraform -chdir=terraform/application output -raw url)
echo "url=${url}" >> $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 deployed to <${{ steps.get-app-url.outputs.url }}>
32 changes: 16 additions & 16 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ GEM
minitest (>= 5.1)
mutex_m
tzinfo (~> 2.0)
addressable (2.8.5)
addressable (2.8.6)
public_suffix (>= 2.0.2, < 6.0)
aes_key_wrap (1.1.0)
annotate (3.2.0)
Expand Down Expand Up @@ -155,7 +155,7 @@ GEM
factory_bot_rails (6.4.2)
factory_bot (~> 6.4)
railties (>= 5.0.0)
faraday (2.7.12)
faraday (2.8.1)
base64
faraday-net_http (>= 2.0, < 3.1)
ruby2_keywords (>= 0.0.4)
Expand All @@ -176,7 +176,7 @@ GEM
activemodel (>= 6.1)
activesupport (>= 6.1)
html-attributes-utils (~> 1)
haml (6.2.3)
haml (6.3.0)
temple (>= 0.8.2)
thor
tilt
Expand All @@ -185,8 +185,8 @@ GEM
activesupport (>= 6.1.4.4)
i18n (1.14.1)
concurrent-ruby (~> 1.0)
io-console (0.7.0)
irb (1.10.1)
io-console (0.7.1)
irb (1.11.0)
rdoc
reline (>= 0.3.8)
jaro_winkler (1.5.6)
Expand Down Expand Up @@ -227,7 +227,7 @@ GEM
minitest (5.20.0)
msgpack (1.7.2)
mutex_m (0.2.0)
net-imap (0.4.7)
net-imap (0.4.8)
date
net-protocol
net-pop (0.1.2)
Expand All @@ -243,7 +243,7 @@ GEM
racc (~> 1.4)
notifications-ruby-client (5.4.0)
jwt (>= 1.5, < 3)
omniauth (2.1.1)
omniauth (2.1.2)
hashie (>= 3.4.6)
rack (>= 2.2.3)
rack-protection
Expand All @@ -267,7 +267,7 @@ GEM
validate_url
webfinger (~> 2.0)
pagy (6.2.0)
parallel (1.23.0)
parallel (1.24.0)
parser (3.2.2.4)
ast (~> 2.4.1)
racc
Expand All @@ -286,13 +286,13 @@ GEM
pry (>= 0.13, < 0.15)
pry-rails (0.3.9)
pry (>= 0.10.4)
psych (5.1.1.1)
psych (5.1.2)
stringio
public_suffix (5.0.4)
puma (6.4.0)
nio4r (~> 2.0)
racc (1.7.3)
rack (2.2.8)
rack (3.0.8)
rack-oauth2 (2.2.0)
activesupport
attr_required
Expand All @@ -302,13 +302,13 @@ GEM
rack (>= 2.1.0)
rack-protection (3.0.6)
rack
rack-session (1.0.2)
rack (< 3)
rack-session (2.0.0)
rack (>= 3.0.0)
rack-test (2.1.0)
rack (>= 1.3)
rackup (1.0.0)
rack (< 3)
webrick
rackup (2.1.0)
rack (>= 3)
webrick (~> 1.8)
rails (7.1.2)
actioncable (= 7.1.2)
actionmailbox (= 7.1.2)
Expand Down Expand Up @@ -350,7 +350,7 @@ GEM
rainbow (3.1.1)
rake (13.1.0)
rbs (2.8.4)
rdoc (6.6.1)
rdoc (6.6.2)
psych (>= 4.0.0)
regexp_parser (2.8.3)
reline (0.4.1)
Expand Down

0 comments on commit 81d3965

Please sign in to comment.