-
Notifications
You must be signed in to change notification settings - Fork 2
44 lines (33 loc) · 1.54 KB
/
prebuild.yml
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
name: Prebuild Database Images
on:
pull_request:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Calculate SHA256 for postgres_primary.dockerfile
id: primary_sha
run: echo "::set-output name=sha256::$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')"
- name: Calculate SHA256 for postgres_replica.dockerfile
id: replica_sha
run: echo "::set-output name=sha256::$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')"
- name: Compute container registry name
run: echo "CR_NAME::$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_ENV
- name: Build and tag primary Docker image
run: docker build -f postgres_primary.dockerfile -t $CR_NAME/postgres_primary:${{ steps.primary_sha.outputs.sha256 }} .
- name: Build and tag replica Docker image
run: docker build -f postgres_replica.dockerfile -t $CR_NAME/postgres_replica:${{ steps.replica_sha.outputs.sha256 }} .
- name: Push primary Docker image
run: docker push $CR_NAME/postgres_primary:${{ steps.primary_sha.outputs.sha256 }}
- name: Push replica Docker image
run: docker push $CR_NAME/postgres_replica:${{ steps.replica_sha.outputs.sha256 }}