Skip to content

Commit

Permalink
debugging
Browse files Browse the repository at this point in the history
  • Loading branch information
alexandraFlavia9 committed Sep 12, 2024
1 parent b2bb7a2 commit c24e79c
Show file tree
Hide file tree
Showing 2 changed files with 94 additions and 0 deletions.
91 changes: 91 additions & 0 deletions .github/workflows/pr-mergePR.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
# workflow to run both yarn && yarn build in the repo when pr is merged to main
name: Publish Connectors

on:
push:
branches:
- test/fix-publish

jobs:
build-and-publish:
# checkout the repo
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [20]
steps:
- uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
registry-url: 'https://npm.pkg.github.com'
scope: '@chili-publish'

- name: Install dependencies
run: yarn
env:
NODE_AUTH_TOKEN: ${{ secrets.PACKAGE_SECRET }}

- name: Download index.json
uses: azure/CLI@v1
with:
inlineScript: |
container_name="connector-marketplace"
blob_name="connector-repo/index.json"
destination_file="existing/index.json"
connection_string="${{ secrets.AZURE_CDN_STUDIO_DEV_CONNECTION_STRING }}"
# ensure 'existing' folder exists
mkdir -p existing
# Check if the blob exists
blob_exists=$(az storage blob exists --name $blob_name --container-name $container_name --connection-string $connection_string --output tsv --query exists)
# If the blob exists, download it
if [ $blob_exists == "true" ]; then
az storage blob download --name $blob_name --file $destination_file --container-name $container_name --connection-string $connection_string --no-progress
else
echo "Blob does not exist."
fi
- name: Determine changed connectors
run: |
if git rev-parse --verify HEAD^ >/dev/null 2>&1; then
echo "Diffing HEAD^ HEAD"
CHANGED_CONNECTOR=$(git diff --name-only HEAD^ HEAD | grep '^src/connectors/' | cut -d/ -f3 | sort | uniq)
else
echo "Diffing HEAD"
CHANGED_CONNECTOR=$(git diff --name-only HEAD | grep '^src/connectors/' | cut -d/ -f3 | sort | uniq)
fi
echo "Changed directories: $CHANGED_CONNECTOR"
echo "CHANGED_CONNECTOR=$CHANGED_CONNECTOR" >> $GITHUB_ENV
- name: Build Cli
run: yarn run build-cli

- name: Build and Publish connectors
if: env.CHANGED_CONNECTOR != ''
run: |
echo "Building and publishing $CHANGED_CONNECTOR"
node scripts/publish.js $CHANGED_CONNECTOR
- name: Copy to upload folder
if: env.CHANGED_CONNECTOR != ''
run: mkdir -p upload/connector-repo && cp -r publish/* upload/connector-repo

- name: Upload artifacts
if: env.CHANGED_CONNECTOR != ''
uses: actions/upload-artifact@v4
with:
name: connectors
path: upload/connector-repo

- name: Upload to Azure
if: env.CHANGED_CONNECTOR != ''
uses: azure/CLI@v1
with:
inlineScript: |
az storage blob upload-batch -d connector-marketplace -s upload/ --connection-string "${{ secrets.AZURE_ST_MARKETPLACE_DEV_CONNECTION_STRING }}" --overwrite true
3 changes: 3 additions & 0 deletions scripts/publish.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,9 @@ fs.readdirSync(publishDir).forEach(file => {
const connectorAllowedDomains = connectorJson.allowedDomains;
const connectorProxyOptions= connectorJson.proxyOptions;

console.log(connectorName, connectorJson);
console.log(indexJson);

if (!indexJson[connectorName]) {
indexJson[connectorName] = {versions: []};
}
Expand Down

0 comments on commit c24e79c

Please sign in to comment.