Skip to content

Commit

Permalink
Merge pull request janhq#416 from janhq/chore/plugin-catalog-auto-pr
Browse files Browse the repository at this point in the history
Add auto create PR to plugin-catalog when a new version of plugin is …
  • Loading branch information
hiento09 authored Oct 20, 2023
2 parents 05b40ac + 9ecc9e7 commit 0f5ef64
Showing 1 changed file with 29 additions and 2 deletions.
31 changes: 29 additions & 2 deletions .github/workflows/jan-plugins.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
build:
runs-on: mac-silicon
environment: production
outputs:
branch_name: ${{ steps.commit_and_tag.outputs.branch_name }}
steps:
- uses: actions/checkout@v4
with:
Expand All @@ -25,7 +27,7 @@ jobs:

- name: Install jq
uses: dcarbone/[email protected]

- name: Check Path Change
run: |
git config --global user.email "[email protected]"
Expand Down Expand Up @@ -84,8 +86,11 @@ jobs:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

- name: "Commit new version to main and create tag"
id: commit_and_tag
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
run: |
rm -rf /tmp/plugin-catalog
git clone https://github.com/janhq/plugin-catalog.git /tmp/plugin-catalog
for dir in $(cat /tmp/change_dir.txt)
do
echo "$dir"
Expand All @@ -97,4 +102,26 @@ jobs:
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin HEAD:main
git tag -a $dir-$version -m "${GITHUB_REPOSITORY}: Update tag build $version for $dir"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $dir-$version
done
plugin_name=$(jq -r '.name | sub("@janhq/"; "")' plugins/$dir/package.json)
cp plugins/$dir/package.json /tmp/plugin-catalog/${plugin_name}.json
done
cd /tmp/plugin-catalog
BRANCH_NAME="update-package-$(date +'%Y%m%d%H%M%S')"
git checkout -b $BRANCH_NAME
git add .
git commit -m "Update plugin catalog"
git -c http.extraheader="AUTHORIZATION: bearer ${{ secrets.PAT_SERVICE_ACCOUNT }}" push origin $BRANCH_NAME
cd /tmp && rm -rf /tmp/plugin-catalog
echo "BRANCH_NAME=$BRANCH_NAME" >> $GITHUB_ENV
echo "::set-output name=branch_name::$BRANCH_NAME"
pull_request:
runs-on: ubuntu-latest
environment: production
if: github.event_name == 'push' && github.event.pull_request.head.repo.full_name != github.repository
needs: build
steps:
- run: |
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
env:
GITHUB_TOKEN: ${{ secrets.PAT_SERVICE_ACCOUNT }}

0 comments on commit 0f5ef64

Please sign in to comment.