diff --git a/.github/workflows/prebuild_postgres_primary.yml b/.github/workflows/prebuild_postgres_primary.yml new file mode 100644 index 0000000..9685808 --- /dev/null +++ b/.github/workflows/prebuild_postgres_primary.yml @@ -0,0 +1,46 @@ +name: Build Postgres Primary Image + +on: + pull_request: + paths: + - 'postgres_primary.dockerfile' + +jobs: + export_variables: + runs-on: ubuntu-latest + + outputs: + primary_image: ${{ steps.compute_container_registry_name.outputs.CR_NAME }}/postgres_primary:${{ steps.calculate_primary_sha.outputs.PRIMARY_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_primary.dockerfile + id: calculate_primary_sha + run: echo "PRIMARY_SHA=$(sha256sum postgres_primary.dockerfile | awk '{ print substr($1, 1, 12) }')" >> $GITHUB_OUTPUT + + prebuild_primary: + 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 primary Docker image + run: docker build -f postgres_primary.dockerfile -t ${{ needs.export_variables.outputs.primary_image }} . + + - name: Push primary Docker image + run: docker push ${{ needs.export_variables.outputs.primary_image }} diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 8c0d8f1..f6ccc80 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -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_primary: - 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 primary Docker image - run: docker build -f postgres_primary.dockerfile -t ${{ needs.export_variables.outputs.primary_image }} . - - - name: Push primary Docker image - run: docker push ${{ needs.export_variables.outputs.primary_image }} - prebuild_replica: needs: export_variables runs-on: ubuntu-latest @@ -91,7 +70,7 @@ jobs: run: bundle exec rubocop rspec: - needs: [export_variables, prebuild_primary, prebuild_replica] + needs: [export_variables, prebuild_replica] runs-on: ubuntu-latest strategy: