Skip to content

Commit

Permalink
Merge branch 'main' into ndc-stripe-v0.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
hgiasac committed Oct 15, 2024
2 parents fc5d6e2 + 0acae13 commit 0f8b910
Show file tree
Hide file tree
Showing 274 changed files with 7,400 additions and 1,735 deletions.
60 changes: 60 additions & 0 deletions .github/workflows/registry-updates-prod.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
name: Update Hub DB from GH Registry (prod)

on:
push:
branches:
- main
paths:
- registry/**

jobs:
update_registry_db:
runs-on: ubuntu-latest
environment: production

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
fetch_depth: 1

- name: Get all connector version package changes
id: connector-version-changed-files
uses: tj-actions/changed-files@v44
with:
json: true
escape_json: false
files: |
registry/**
- name: Print out all the changed filse
env:
ADDED_FILES: ${{ steps.connector-version-changed-files.outputs.added_files }}
MODIFIED_FILES: ${{ steps.connector-version-changed-files.outputs.modified_files }}
DELETED_FILES: ${{ steps.connector-version-changed-files.outputs.deleted_files }}
run: |
echo "{\"added_files\": $ADDED_FILES, \"modified_files\": $MODIFIED_FILES, \"deleted_files\": $DELETED_FILES}" > changed_files.json
- name: List changed files
id: list_files
run: |
cat changed_files.json
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: Run registry automation program
env:
CHANGED_FILES_PATH: "changed_files.json"
PUBLICATION_ENV: "production"
CONNECTOR_REGISTRY_GQL_URL: ${{ secrets.CONNECTOR_REGISTRY_GQL_URL }}
GCP_BUCKET_NAME: ${{ secrets.GCP_BUCKET_NAME }}
GCP_SERVICE_ACCOUNT_DETAILS: ${{ secrets.GCP_SERVICE_ACCOUNT_DETAILS }}
CONNECTOR_PUBLICATION_KEY: ${{ secrets.CONNECTOR_PUBLICATION_KEY }}
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
run: |
mv changed_files.json registry-automation/changed_files.json
cd registry-automation
go run main.go ci
83 changes: 83 additions & 0 deletions .github/workflows/registry-updates.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,83 @@
name: Update Hub DB from GH Registry (Staging)

on:
pull_request_target:
branches:
- main
types: [opened, synchronize, reopened]
paths:
- registry/**

jobs:
update_registry_db:
runs-on: ubuntu-latest
environment: staging

steps:
- name: Checkout repository
uses: actions/checkout@v2
with:
# In the case of forked PRs, the forked repository will
# be checked out.
ref: ${{github.event.pull_request.head.ref}}
repository: ${{github.event.pull_request.head.repo.full_name}}
fetch-depth: 1

- name: Check for PR approvals
id: check-approval
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.issue;
const pull_number = context.payload.pull_request.number;
console.log("Owner and repo and pull_number", owner, repo, pull_number);
const { data: reviews } = await github.rest.pulls.listReviews({
owner: context.repo.owner,
repo: context.repo.repo,
pull_number: context.payload.pull_request.number,
});
const approved = reviews.some(review => review.state === 'APPROVED');
if (!approved) {
core.setFailed('This workflow will only run when the PR is approved by someone in Hasura')
}
- name: Get all connector version package changes
id: connector-version-changed-files
uses: tj-actions/changed-files@v44
with:
json: true
escape_json: false
files: |
registry/**
- name: Print out all the changed filse
env:
ADDED_FILES: ${{ steps.connector-version-changed-files.outputs.added_files }}
MODIFIED_FILES: ${{ steps.connector-version-changed-files.outputs.modified_files }}
DELETED_FILES: ${{ steps.connector-version-changed-files.outputs.deleted_files }}
run: |
echo "{\"added_files\": $ADDED_FILES, \"modified_files\": $MODIFIED_FILES, \"deleted_files\": $DELETED_FILES}" > changed_files.json
- name: List changed files
id: list_files
run: |
cat changed_files.json
- name: Setup Go
uses: actions/setup-go@v4
with:
go-version: 1.21.x

- name: Run registry automation program
env:
CHANGED_FILES_PATH: "changed_files.json"
PUBLICATION_ENV: "staging"
CONNECTOR_REGISTRY_GQL_URL: ${{ secrets.CONNECTOR_REGISTRY_GQL_URL }}
GCP_BUCKET_NAME: ${{ secrets.GCP_BUCKET_NAME }}
GCP_SERVICE_ACCOUNT_DETAILS: ${{ secrets.GCP_SERVICE_ACCOUNT_DETAILS }}
CONNECTOR_PUBLICATION_KEY: ${{ secrets.CONNECTOR_PUBLICATION_KEY }}
CLOUDINARY_URL: ${{ secrets.CLOUDINARY_URL }}
run: |
mv changed_files.json registry-automation/changed_files.json
cd registry-automation
go run main.go ci
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,4 @@

# testing
/tmp/empty
registry-automation/extracted_tgz
201 changes: 0 additions & 201 deletions LICENSE

This file was deleted.

1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -40,3 +40,4 @@ implementation][NDC reference].

[NDC specification]: http://hasura.github.io/ndc-spec/
[NDC reference]: https://github.com/hasura/ndc-spec/tree/main/ndc-reference

38 changes: 38 additions & 0 deletions registry-automation/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
# Introduction

## Steps to runs

1. Consider the following `changed_files.json` file:
```json

{
"added_files": [
"registry/hasura/azure-cosmos/releases/v0.1.6/connector-packaging.json"
],
"modified_files": [
"registry/hasura/azure-cosmos/metadata.json"
],
"deleted_files": []
}
```

2. You will require the following environment variables:

1. GCP_BUCKET_NAME
2. CLOUDINARY_URL
3. GCP_SERVICE_ACCOUNT_KEY
4. CONNECTOR_REGISTRY_GQL_URL
5. CONNECTOR_PUBLICATION_KEY
6. GCP_SERVICE_ACCOUNT_DETAILS



```bash


2. Run the following command from the `registry-automation` directory:


```bash
go run main.go ci --changed-files-path changed_files.json
```
Loading

0 comments on commit 0f8b910

Please sign in to comment.