Skip to content

Nhudson/image ci fix #215

Nhudson/image ci fix

Nhudson/image ci fix #215

Workflow file for this run

name: Build and push images
on:
pull_request: {}
push:
branches: ['main']
jobs:
find_directories:
name: Find directories with Dockerfiles
runs-on: ubuntu-20.04
outputs:
build_images: ${{ steps.find_directories.outputs.build_matrix }}
short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
branch_name: ${{ steps.versions.outputs.BRANCH_NAME }}
build_matrix: ${{ steps.append_pg_configs.outputs.build_matrix }}
steps:
- name: Check out the repo
uses: actions/checkout@v3
- name: Set version strings
id: versions
run: |
echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
echo "BRANCH_NAME=$(git rev-parse --abbrev-ref HEAD)" >> $GITHUB_OUTPUT
- name: Find directories with Dockerfiles that changed
id: find_directories
uses: ./.github/actions/find-changed-directories
with:
contains_the_file: Dockerfile
# If the branch does not exist, then it will not
# filter any directories containing the file.
# This allows for filtering out unchanged directories
# in a pull request, and using all directories on the release
# or main branches.
changed_relative_to_ref: origin/${{ github.base_ref || 'not-a-branch' }}
- name: Append PostgreSQL configurations to matrix
id: append_pg_configs
run: |
# Read the initial matrix from the output of a previous step
INITIAL_MATRIX="${{ toJson(steps.find_directories.outputs.build_matrix) }}"
echo "Initial Matrix: $INITIAL_MATRIX"
# Define PostgreSQL configurations to append
PG_CONFIGS='[{"pg_release": "14.10", "pg_version": "14"}, {"pg_release": "15.3", "pg_version": "15"}, {"pg_release": "16.1", "pg_version": "16"}]'
# Use jq to properly append the configurations, ensuring valid JSON format
# Note: This requires jq to be installed or available in the runner environment
MODIFIED_MATRIX=$(echo $INITIAL_MATRIX | jq -c --argjson pgConfigs "$PG_CONFIGS" '.include += $pgConfigs')
echo "Modified Matrix: $MODIFIED_MATRIX"
# Use the new syntax for setting outputs
echo "build_matrix=$MODIFIED_MATRIX" >> $GITHUB_OUTPUT
- name: Debug outputs
run: |
echo "Build Images: ${{ steps.find_directories.outputs.build_images }}"
echo "Short SHA: ${{ steps.versions.outputs.SHORT_SHA }}"
echo "Branch Name: ${{ steps.versions.outputs.BRANCH_NAME }}"
echo "Build Matrix: ${{ steps.append_pg_configs.outputs.build_matrix }}"
# build_and_push:
# name: Build and push images
# permissions:
# id-token: write
# contents: read
# runs-on:
# - self-hosted
# - dind
# - large-8x8
# needs:
# - find_directories
# strategy:
# fail-fast: false
# matrix: ${{ fromJson(needs.find_directories.outputs.build_images) }}
# outputs:
# short_sha: ${{ steps.versions.outputs.SHORT_SHA }}
# steps:
# - name: Check out the repo
# uses: actions/checkout@v3
# - name: Set version strings
# id: versions
# run: |
# echo "SHORT_SHA=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
# - name: Determine which tags to publish
# id: tags
# run: |
# BRANCH_NAME="${{ needs.find_directories.outputs.branch_name }}"
# if [ "${BRANCH_NAME}" == "main" ]; then
# echo "tag_latest=true" >> $GITHUB_OUTPUT
# echo "tag_cargo=true" >> $GITHUB_OUTPUT
# elif [[ "${BRANCH_NAME}" == release/* ]]; then
# echo "tag_cargo=true" >> $GITHUB_OUTPUT
# echo "tag_latest=false" >> $GITHUB_OUTPUT
# else
# echo "tag_latest=false" >> $GITHUB_OUTPUT
# echo "tag_cargo=false" >> $GITHUB_OUTPUT
# fi
# - name: Build and upload image
# uses: ./.github/actions/build-and-push-to-quay
# with:
# image_name: ${{ matrix.name }}
# docker_directory: ${{ matrix.path }}
# registry: "quay.io/tembo"
# tag_cargo_version_if_present: ${{ steps.tags.outputs.tag_cargo }}
# publish_latest: ${{ steps.tags.outputs.tag_latest }}
# publish_calver: ${{ steps.tags_outputs.tag_latest }}
# quay_user: ${{ secrets.QUAY_USER_TEMBO }}
# quay_password: ${{ secrets.QUAY_PASSWORD_TEMBO }}
# quay_user_tembo: ${{ secrets.QUAY_USER_TEMBO }}
# quay_password_tembo: ${{ secrets.QUAY_PASSWORD_TEMBO }}
# gha_iam_role: ${{ secrets.GHA_IAM_ROLE }}
# ecr_registry: ${{ secrets.ECR_REGISTRY }}
# pg_version: ${{ matrix.pg_version }}