ToolJet/.github/workflows/maketplace-plugins-deploy.yml
Adish M bd3b21ce3e
Render refactor and Fix for Marketplace plugin workflow (#12911)
* Render refactor

* fixed the issue with commenting

* fix clear cache api

* enhanced the comment

* fixed the issue with comment not fetched by action

* issue with if condition intendation

* testing clear and push commint comment

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* fix for comment trirgger

* adding back to labels

* adding back to labels

* fixing fetching detail from api

* fixing fetching detail from api

* fixing fetching detail from api

* fixing fetching detail from api

* adding the comment option for triggerring

* fix label trigger

* fix label trigger

* fix label trigger

* fix label trigger

* fix label trigger

* adding failure notification on marketplace plugin failure

* update s3 bucket upload script with error logs

* update the aws/sdk package

* Adding the github action url to the PR comment

* Adding the output from s3 upload output for better understanding

* fix the build error due common files issue

* fix the build error due common files issue

* adding the submdoule file
2025-05-21 19:01:25 +05:30

136 lines
No EOL
4.7 KiB
YAML

name: Maketplace plugin build
on:
pull_request_target:
types: [labeled, unlabeled, closed]
workflow_dispatch:
env:
PR_NUMBER: ${{ github.event.number }}
BRANCH_NAME: ${{ github.head_ref || github.ref_name }}
jobs:
deploy-marketplace-plugin:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'deploy-marketplace-plugin' }}
runs-on: ubuntu-latest
steps:
- name: Sync repo
uses: actions/checkout@v3
- name: Check if PR is from the same repo
id: check_repo
run: echo "::set-output name=is_fork::$(if [[ '${{ github.event.pull_request.head.repo.full_name }}' != '${{ github.event.pull_request.base.repo.full_name }}' ]]; then echo true; else echo false; fi)"
- name: Fetch the remote branch if it's a forked PR
if: steps.check_repo.outputs.is_fork == 'true'
run: |
git fetch origin pull/${{ github.event.number }}/head:${{ env.BRANCH_NAME }}
git checkout ${{ env.BRANCH_NAME }}
- name: Checkout
if: steps.check_repo.outputs.is_fork == 'false'
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 18.18.2
- name: Configure AWS Credentials
uses: aws-actions/configure-aws-credentials@v4
with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_MAR_KEY_ID }}
aws-secret-access-key: ${{ secrets.AWS_SECRET_MAR_ACCESS_KEY }}
aws-region: us-east-2
- name: Install and build dependencies in order
run: |
cd marketplace
echo "🔧 Installing all workspace dependencies"
npm install
echo "🏗️ Building 'common' plugin first"
npm run build --workspace=plugins/common || exit 1
echo "🔁 Building all remaining plugins"
PLUGINS=$(ls plugins | grep -v '^common$')
for plugin in $PLUGINS; do
echo "🔨 Building plugin: $plugin"
npm run build --workspace=plugins/$plugin || exit 1
done
- name: Build marketplace plugins and capture summary
run: |
cd marketplace
echo "🚀 Uploading to S3"
AWS_BUCKET=tooljet-plugins-stage node scripts/upload-to-s3.js | tee upload_summary.log
- name: Extract upload summary
id: upload_summary
run: |
SUMMARY=$(awk '/UPLOAD SUMMARY/,0' marketplace/upload_summary.log)
echo "UPLOAD_SUMMARY<<EOF" >> $GITHUB_ENV
echo "$SUMMARY" >> $GITHUB_ENV
echo "EOF" >> $GITHUB_ENV
- name: Comment on success
if: success()
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runId = process.env.GITHUB_RUN_ID;
const runUrl = `https://github.com/${{ github.repository }}/actions/runs/${runId}`;
const summary = process.env.UPLOAD_SUMMARY;
const body = `Marketplace Plugin added to stage bucket\n\n🔍 [View Deployment Logs & Summary](${runUrl})\n\n\`\`\`\n${summary}\n\`\`\``;
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body
});
- name: Label update on success
if: success()
uses: actions/github-script@v6
with:
script: |
try {
await github.rest.issues.removeLabel({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
name: 'deploy-marketplace-plugin'
})
} catch (e) {
console.log(e)
}
await github.rest.issues.addLabels({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
labels: ['marketplace-plugin-deployed']
})
- name: Comment on failure
if: failure()
uses: actions/github-script@v6
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const runId = process.env.GITHUB_RUN_ID;
const runUrl = `https://github.com/${{ github.repository }}/actions/runs/${runId}`;
await github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: `❌ Marketplace Plugin deployment failed.\n\n🔍 [View Deployment Logs & Summary](${runUrl})`
});