forked from ToolJet/ToolJet
-
Notifications
You must be signed in to change notification settings - Fork 0
136 lines (114 loc) · 4.68 KB
/
maketplace-plugins-deploy.yml
File metadata and controls
136 lines (114 loc) · 4.68 KB
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
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
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})`
});