CRIMAP-442 User manager cannot act as caseworkers in production #1285
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: CI and CD | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
env: | |
RACK_ENV: test | |
RAILS_ENV: test | |
DATABASE_URL: "postgresql://postgres:[email protected]/laa-review-criminal-legal-aid-test" | |
services: | |
postgres: | |
image: postgres:15.2-alpine | |
env: | |
POSTGRES_DB: laa-review-criminal-legal-aid-test | |
POSTGRES_USER: postgres | |
POSTGRES_PASSWORD: postgres | |
ports: | |
- 5432:5432 | |
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Setup Ruby and install gems | |
uses: ruby/setup-ruby@v1 | |
with: | |
bundler-cache: true | |
- name: Find yarn cache location | |
id: yarn-cache-dir-path | |
run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
- name: JS package cache | |
uses: actions/cache@v3 | |
id: yarn-cache | |
with: | |
path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: | | |
${{ runner.os }}-yarn- | |
- name: Install packages with yarn | |
run: yarn install --frozen-lockfile --ignore-scripts | |
- name: Precompile assets | |
run: bin/rails assets:precompile | |
- name: Setup test database | |
run: bin/rails db:prepare | |
- name: Run linters and tests | |
run: bundle exec rake | |
- name: Upload rspec coverage (if failure) | |
if: failure() | |
uses: actions/upload-artifact@v3 | |
with: | |
name: rspec-coverage | |
path: coverage/* | |
build: | |
runs-on: ubuntu-latest | |
needs: test | |
if: github.ref == 'refs/heads/main' | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Store current date | |
run: echo "BUILD_DATE=$(date +%Y%m%d%H%M)" >> $GITHUB_ENV | |
- name: Build | |
run: | | |
docker build \ | |
--label build.git.sha=${{ github.sha }} \ | |
--label build.git.branch=${{ github.ref }} \ | |
--label build.date=${{ env.BUILD_DATE }} \ | |
--build-arg APP_BUILD_DATE=${{ env.BUILD_DATE }} \ | |
--build-arg APP_BUILD_TAG=${{ github.ref }} \ | |
--build-arg APP_GIT_COMMIT=${{ github.sha }} \ | |
-t app . | |
- name: Push to ECR | |
id: ecr | |
uses: jwalton/gh-ecr-push@b10a019116283fff10914554dfe85bfb1c21d41b | |
with: | |
access-key-id: ${{ secrets.ECR_AWS_ACCESS_KEY_ID }} | |
secret-access-key: ${{ secrets.ECR_AWS_SECRET_ACCESS_KEY }} | |
region: eu-west-2 | |
local-image: app | |
image: ${{ secrets.ECR_NAME }}:${{ github.sha }}, ${{ secrets.ECR_NAME }}:staging.latest | |
deploy-staging: | |
runs-on: ubuntu-latest | |
needs: build | |
environment: staging | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Deploy staging | |
uses: ./.github/actions/deploy | |
with: | |
environment-name: staging | |
git-crypt-key: ${{ secrets.GIT_CRYPT_KEY }} | |
ecr-url: ${{ secrets.ECR_URL }} | |
kube-cert: ${{ secrets.KUBE_STAGING_CERT }} | |
kube-token: ${{ secrets.KUBE_STAGING_TOKEN }} | |
kube-cluster: ${{ secrets.KUBE_STAGING_CLUSTER }} | |
kube-namespace: ${{ secrets.KUBE_STAGING_NAMESPACE }} | |
deploy-production: | |
runs-on: ubuntu-latest | |
needs: deploy-staging | |
environment: production | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Deploy production | |
uses: ./.github/actions/deploy | |
with: | |
environment-name: production | |
git-crypt-key: ${{ secrets.GIT_CRYPT_KEY }} | |
ecr-url: ${{ secrets.ECR_URL }} | |
kube-cert: ${{ secrets.KUBE_PRODUCTION_CERT }} | |
kube-token: ${{ secrets.KUBE_PRODUCTION_TOKEN }} | |
kube-cluster: ${{ secrets.KUBE_PRODUCTION_CLUSTER }} | |
kube-namespace: ${{ secrets.KUBE_PRODUCTION_NAMESPACE }} |