Add CI pipeline #1
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: Prebuild Database Images | |
on: | |
pull_request: | |
branches: | |
- main | |
jobs: | |
prebuild: | |
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 | |
run: echo "PRIMARY_SHA=$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_ENV | |
- name: Calculate SHA256 for postgres_replica.dockerfile | |
run: echo "REPLICA_SHA=$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_ENV | |
- 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:${{ env.PRIMARY_SHA }} . | |
- name: Build and tag replica Docker image | |
run: docker build -f postgres_replica.dockerfile -t $CR_NAME/postgres_replica:${{ env.REPLICA_SHA }} . | |
- name: Push primary Docker image | |
run: docker push $CR_NAME/postgres_primary:${{ env.PRIMARY_SHA }} | |
- name: Push replica Docker image | |
run: docker push $CR_NAME/postgres_replica:${{ env.REPLICA_SHA }} |