-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (86 loc) · 3.4 KB
/
build-connectors-action.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
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 }}