Skip to content

Update ConnectorConfig loader #23

Update ConnectorConfig loader

Update ConnectorConfig loader #23

name: Build and Release Database Connector
on:
push:
branches:
- "snowflake/*"
- "mysql/*"
- "oracle/*"
- "phoenix/*"
jobs:
docker-build:
runs-on: ubuntu-latest
strategy:
matrix:
database: [snowflake, mysql, oracle, phoenix]
outputs:
release_tag: ${{ steps.extract_tag.outputs.tag }}
permissions:
contents: read
packages: write # Allows pushing to GHCR
id-token: write # Required for authenticating with GHCR
steps:
- name: Checkout repository
if: contains(github.ref, matrix.database)
uses: actions/checkout@v3
- name: Extract version from branch name
if: contains(github.ref, matrix.database)
id: extract_tag
run: |
# Get the database type from the matrix
DB_TYPE=${{ matrix.database }}
# Use sed to remove the database prefix and get only the version part
VERSION=$(echo "${GITHUB_REF#refs/heads/}" | sed "s|^${DB_TYPE}/||")
# Construct the Docker tag
echo "docker_tag=ghcr.io/hasura/ndc-jvm-${DB_TYPE}:${VERSION}" >> $GITHUB_OUTPUT
- name: Log in to the Container registry
uses: docker/login-action@65b78e6e13532edd9afa3aa52ac7964289d1a9c1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up Docker Buildx
if: contains(github.ref, matrix.database)
uses: docker/setup-buildx-action@v2
- name: Cross-platform Docker build and push
if: contains(github.ref, matrix.database)
uses: docker/build-push-action@v5
with:
context: .
file: ndc-connector-${{ matrix.database }}.dockerfile
push: true
tags: ${{ steps.extract_tag.outputs.docker_tag }}
platforms: linux/amd64,linux/arm64
build-args: |
JOOQ_PRO_EMAIL=${{ secrets.JOOQ_PRO_EMAIL }}
JOOQ_PRO_LICENSE=${{ secrets.JOOQ_PRO_LICENSE }}
create-release:
needs: docker-build
runs-on: ubuntu-latest
strategy:
matrix:
database: [snowflake, mysql, oracle, phoenix]
steps:
- name: Checkout repository
if: contains(github.ref, matrix.database)
uses: actions/checkout@v3
- name: Update dockerImage in connector-metadata.yaml
if: contains(github.ref, matrix.database)
run: |
# Use the full Docker tag from the docker-build job output
sed -i "s|^ dockerImage:.*| dockerImage: \"${{ needs.docker-build.outputs.docker_tag }}\"|" ndc-connector-${{ matrix.database }}/.hasura-connector/connector-metadata.yaml
- name: Compress Hasura Connector Metadata
if: contains(github.ref, matrix.database)
run: |
cd ndc-connector-${{ matrix.database }}
tar -czf package.tar.gz ./.hasura-connector
- name: Upload package.tar.gz to GitHub Release
if: contains(github.ref, matrix.database)
uses: actions/upload-release-asset@v1
with:
tag_name: ${{ needs.docker-build.outputs.tag }} # Use the correct tag output
upload_url: ${{ steps.release.outputs.upload_url }}
asset_path: ndc-connector-${{ matrix.database }}/package.tar.gz
asset_name: package-${{ matrix.database }}.tar.gz
asset_content_type: application/gzip
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}