Skip to content

Commit 0f5ef64

Browse files
authored
Merge pull request #416 from janhq/chore/plugin-catalog-auto-pr
Add auto create PR to plugin-catalog when a new version of plugin is …
2 parents 05b40ac + 9ecc9e7 commit 0f5ef64

File tree

1 file changed

+29
-2
lines changed

1 file changed

+29
-2
lines changed

.github/workflows/jan-plugins.yml

Lines changed: 29 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ jobs:
1717
build:
1818
runs-on: mac-silicon
1919
environment: production
20+
outputs:
21+
branch_name: ${{ steps.commit_and_tag.outputs.branch_name }}
2022
steps:
2123
- uses: actions/checkout@v4
2224
with:
@@ -25,7 +27,7 @@ jobs:
2527

2628
- name: Install jq
2729
uses: dcarbone/[email protected]
28-
30+
2931
- name: Check Path Change
3032
run: |
3133
git config --global user.email "[email protected]"
@@ -84,8 +86,11 @@ jobs:
8486
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
8587

8688
- name: "Commit new version to main and create tag"
89+
id: commit_and_tag
8790
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
8891
run: |
92+
rm -rf /tmp/plugin-catalog
93+
git clone https://github.com/janhq/plugin-catalog.git /tmp/plugin-catalog
8994
for dir in $(cat /tmp/change_dir.txt)
9095
do
9196
echo "$dir"
@@ -97,4 +102,26 @@ jobs:
97102
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main
98103
git tag -a $dir-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
99104
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $dir-$version
100-
done
105+
plugin_name=$(jq -r '.name | sub("@janhq/"; "")' plugins/$dir/package.json)
106+
cp plugins/$dir/package.json /tmp/plugin-catalog/${plugin_name}.json
107+
done
108+
cd /tmp/plugin-catalog
109+
BRANCH_NAME="update-package-$(date +'%Y%m%d%H%M%S')"
110+
git checkout -b $BRANCH_NAME
111+
git add .
112+
git commit -m "Update plugin catalog"
113+
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $BRANCH_NAME
114+
cd /tmp && rm -rf /tmp/plugin-catalog
115+
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
116+
echo "::set-output name=branch_name::$BRANCH_NAME"
117+
118+
pull_request:
119+
runs-on: ubuntu-latest
120+
environment: production
121+
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
122+
needs: build
123+
steps:
124+
- run: |
125+
gh pr create --title "Update plugin catalog" --body "Update plugin catalog" --base main --head ${{ needs.build.outputs.branch_name }} --repo janhq/plugin-catalog --reviewer louis-jan,hiento09
126+
env:
127+
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}

0 commit comments

Comments
 (0)