Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

wip #52

Closed
wants to merge 13 commits into from
Closed

wip #52

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
43 changes: 43 additions & 0 deletions .github/workflows/delete_review_app_aks.yml
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
106 changes: 106 additions & 0 deletions .github/workflows/deploy_aks.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
name: Build and deploy to AKS cluster

on:
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>
2 changes: 2 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@

# Build builder image
FROM ruby:3.2.2-alpine as builder
ARG SIGN_IN_METHOD
ENV SIGN_IN_METHOD=${SIGN_IN_METHOD}

# RUN apk -U upgrade && \
# apk add --update --no-cache gcc git libc6-compat libc-dev make nodejs \
Expand Down