-
Notifications
You must be signed in to change notification settings - Fork 2
91 lines (78 loc) · 3.14 KB
/
pr-merge.yml
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
# workflow to run both yarn && yarn build in the repo when pr is merged to main
name: Publish Connectors
on:
push:
branches:
- main
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_ST_MARKETPLACE_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