Skip to content

Commit

Permalink
Move prebuild of Postgres replica to separate workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
mateuscruz committed Nov 30, 2024
1 parent 9e53574 commit de335f9
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 22 deletions.
46 changes: 46 additions & 0 deletions .github/workflows/prebuild_postgres_replica.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Build Postgres Replica Image

on:
pull_request:
paths:
- 'postgres_replica.dockerfile'

jobs:
export_variables:
runs-on: ubuntu-latest

outputs:
replica_image: ${{ steps.compute_container_registry_name.outputs.CR_NAME }}/postgres_replica:${{ steps.calculate_replica_sha.outputs.REPLICA_SHA }}

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Compute container registry name
id: compute_container_registry_name
run: echo "CR_NAME=$(echo ghcr.io/${{ github.repository }} | tr '[:upper:]' '[:lower:]')" >> $GITHUB_OUTPUT

- name: Calculate SHA256 for postgres_replica.dockerfile
id: calculate_replica_sha
run: echo "REPLICA_SHA=$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT

prebuild_replica:
needs: export_variables
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and tag replica Docker image
run: docker build -f postgres_replica.dockerfile -t ${{ needs.export_variables.outputs.replica_image }} .

- name: Push replica Docker image
run: docker push ${{ needs.export_variables.outputs.replica_image }}
23 changes: 1 addition & 22 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -29,27 +29,6 @@ jobs:
id: calculate_replica_sha
run: echo "REPLICA_SHA=$(sha256sum postgres_replica.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT

prebuild_replica:
needs: export_variables
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and tag replica Docker image
run: docker build -f postgres_replica.dockerfile -t ${{ needs.export_variables.outputs.replica_image }} .

- name: Push replica Docker image
run: docker push ${{ needs.export_variables.outputs.replica_image }}

rubocop:
runs-on: ubuntu-latest

Expand All @@ -70,7 +49,7 @@ jobs:
run: bundle exec rubocop

rspec:
needs: [export_variables, prebuild_replica]
needs: [export_variables]
runs-on: ubuntu-latest

strategy:
Expand Down

0 comments on commit de335f9

Please sign in to comment.