-
Notifications
You must be signed in to change notification settings - Fork 16
89 lines (86 loc) · 3.21 KB
/
create_dockerized_db.yml
File metadata and controls
89 lines (86 loc) · 3.21 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
name: Create Dockerized Database
run-name: Creating dockerized image from ${{ github.ref_name }}
on:
workflow_dispatch:
push:
branches:
- next
workflow_call:
inputs:
github_ref:
description: The git commit sha to build the image from.
type: string
permissions:
id-token: write
contents: read
jobs:
setup-development-database:
name: Setup Development Database
runs-on: ubuntu-latest
env:
RAILS_ENV: development
DATABASE_HOST: localhost
DATABASE_USER: postgres
DATABASE_PASSWORD: postgres
BUNDLE_WITHOUT: test
RAILS_MASTER_KEY: intentionally-insecure-dev-key00
SKIP_TEST_DATABASE: true
steps:
- uses: actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd # v6.0.2
with:
ref: ${{ inputs.github_ref || github.ref_name == 'next' && 'next' || github.ref_name }}
repository: nhsuk/manage-vaccinations-in-schools
- uses: actions/setup-node@53b83947a5a98c8d113130e565377fae1a50d02f # v6.3.0
with:
node-version-file: .tool-versions
cache: yarn
- name: Build custom postgres image
run: |
echo -e "FROM postgres:16.11\n\nENV PGDATA=\"/var/lib/postgresql/mydata\"" > db.Dockerfile
docker build -t custom-postgres:latest -f db.Dockerfile .
- name: Start db container
run: |
docker run -d \
--name database \
-e "POSTGRES_HOST_AUTH_METHOD=trust" \
-p 5432:5432 \
custom-postgres:latest
- name: Wait for db to be ready
run: |
docker exec database bash -c '
until pg_isready -U postgres; do
echo "Waiting for postgres..."
sleep 2
done
'
- uses: ruby/setup-ruby@60ecfba8750476ff216b59eee3b88218bb5111cc # v1.303.0
with:
bundler-cache: true
- name: Populate database for testing
run: |
bin/rails db:setup
bin/rails feature_flags:enable_for_development
bin/mavis gias import --input-file=spec/fixtures/dfe-schools.zip
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@ec61189d14ec14c8efccab744f656cffd0e33f37 # v6.1.0
with:
role-to-assume: arn:aws:iam::393416225559:role/GitHubAssuranceTestRole
aws-region: eu-west-2
- name: Login to ECR
id: login-ecr
uses: aws-actions/amazon-ecr-login@376925c9d111252e87ae59691e5a442dd100ef6a # v2.1.3
# yamllint disable rule:line-length
- name: get github ref short
id: github-ref
run: |
git_ref=$(git rev-parse ${{ inputs.github_ref || github.ref_name == 'next' && 'origin/next' || github.ref_name }})
echo "ref=$git_ref" >> "$GITHUB_OUTPUT"
- name: Commit postgres container with database
run: >-
docker commit database "${{ steps.login-ecr.outputs.registry
}}/mavis/development/postgres_db:${{ steps.github-ref.outputs.ref }}"
- name: Push image
run: >-
docker push "${{ steps.login-ecr.outputs.registry }}/mavis/development/postgres_db:${{
steps.github-ref.outputs.ref }}"
# yamllint enable rule:line-length