Skip to content

Commit 63ec12f

Browse files
author
Tristen Harr
committed
attempt update workflow
1 parent 5bdfa30 commit 63ec12f

File tree

1 file changed

+89
-4
lines changed

1 file changed

+89
-4
lines changed

.github/workflows/ndc-python-lambda-connector.yaml

Lines changed: 89 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,9 @@ jobs:
3939
build-connector:
4040
name: Build connector
4141
runs-on: ubuntu-latest
42+
outputs:
43+
commit_hash: ${{ steps.get_commit_hash.outputs.commit_hash }}
44+
sha256: ${{ steps.calculate_checksum.outputs.sha256 }}
4245
steps:
4346
- uses: actions/checkout@v4
4447
with:
@@ -50,6 +53,16 @@ jobs:
5053
run: |
5154
cd connector-definition
5255
make build
56+
- name: Calculate SHA256 checksum
57+
id: calculate_checksum
58+
run: |
59+
SHA256=$(sha256sum ./connector-definition/dist/connector-definition.tgz | awk '{ print $1 }')
60+
echo "sha256=$SHA256" >> $GITHUB_OUTPUT
61+
- name: Get commit hash
62+
id: get_commit_hash
63+
run: |
64+
COMMIT_HASH=$(git rev-parse HEAD)
65+
echo "commit_hash=$COMMIT_HASH" >> $GITHUB_OUTPUT
5366
- name: Debug information
5467
run: |
5568
echo "Contents of connector-definition/dist:"
@@ -69,13 +82,10 @@ jobs:
6982
if: startsWith(github.ref, 'refs/tags/v')
7083
steps:
7184
- uses: actions/checkout@v4
72-
7385
- name: Set up QEMU
7486
uses: docker/setup-qemu-action@v2
75-
7687
- name: Set up Docker Buildx
7788
uses: docker/setup-buildx-action@v3
78-
7989
- name: Login to GitHub Container Registry
8090
uses: docker/login-action@v3
8191
with:
@@ -128,4 +138,79 @@ jobs:
128138
body: ${{ steps.changelog-reader.outputs.changes }}
129139
files: |
130140
./connector-definition/dist/connector-definition.tgz
131-
fail_on_unmatched_files: true
141+
fail_on_unmatched_files: true
142+
143+
- name: Update ndc-hub
144+
env:
145+
REGISTRY_NAME: hasura
146+
CONNECTOR_NAME: ndc-python-lambda
147+
COMMIT_HASH: ${{ needs.build-connector.outputs.commit_hash }}
148+
SHA256: ${{ needs.build-connector.outputs.sha256 }}
149+
GH_TOKEN: ${{ secrets.PAT_TOKEN }}
150+
run: |
151+
# Clone ndc-hub repository
152+
git clone https://github.com/hasura/ndc-hub.git
153+
cd ndc-hub
154+
155+
# Create a new branch
156+
NEW_BRANCH="update-${{ env.CONNECTOR_NAME }}-connector-v${{ steps.get-version.outputs.tagged_version }}"
157+
git checkout -b $NEW_BRANCH
158+
159+
cd registry/${{ env.REGISTRY_NAME }}/${{ env.CONNECTOR_NAME }}
160+
161+
# Create releases directory if it doesn't exist
162+
mkdir -p releases/v${{ steps.get-version.outputs.tagged_version }}
163+
164+
# Create connector-packaging.json
165+
cat << EOF > releases/v${{ steps.get-version.outputs.tagged_version }}/connector-packaging.json
166+
{
167+
"version": "v${{ steps.get-version.outputs.tagged_version }}",
168+
"uri": "https://github.com/${{ github.repository }}/releases/download/v${{ steps.get-version.outputs.tagged_version }}/connector-definition.tgz",
169+
"checksum": {
170+
"type": "sha256",
171+
"value": "$SHA256"
172+
},
173+
"source": {
174+
"hash": "$COMMIT_HASH"
175+
}
176+
}
177+
EOF
178+
179+
# Update metadata.json to remove 'packages' field if it exists and update 'latest_version'
180+
jq --arg version_tag "v${{ steps.get-version.outputs.tagged_version }}" \
181+
--arg commit_hash "$COMMIT_HASH" \
182+
'if has("packages") then del(.packages) else . end |
183+
.overview.latest_version = $version_tag |
184+
if has("source_code") then
185+
.source_code.version += [{
186+
"tag": $version_tag,
187+
"hash": $commit_hash,
188+
"is_verified": false
189+
}]
190+
else
191+
. + {"source_code": {"version": [{
192+
"tag": $version_tag,
193+
"hash": $commit_hash,
194+
"is_verified": false
195+
}]}}
196+
end' \
197+
metadata.json > tmp.json && mv tmp.json metadata.json
198+
199+
cp ../../../../README.md ./README.md
200+
201+
# Commit changes
202+
git config user.name "GitHub Action"
203+
git config user.email "[email protected]"
204+
git add metadata.json README.md releases
205+
git commit -m "Update ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}"
206+
207+
# Push changes
208+
git push https://${{ secrets.PAT_TOKEN }}@github.com/hasura/ndc-hub.git HEAD:$NEW_BRANCH
209+
210+
# Create PR using GitHub CLI
211+
cd ../..
212+
gh pr create --repo hasura/ndc-hub \
213+
--base main \
214+
--head $NEW_BRANCH \
215+
--title "Update ${{ env.CONNECTOR_NAME }} connector to v${{ steps.get-version.outputs.tagged_version }}" \
216+
--body "This PR updates the ${{ env.CONNECTOR_NAME }} connector metadata to version ${{ steps.get-version.outputs.tagged_version }}."

0 commit comments

Comments
 (0)