ToolJet/.github/workflows/maketplace-plugins-deploy.yml

161 lines
5.1 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: Checkout
uses: actions/checkout@v3
with:
ref: ${{ github.event.pull_request.head.ref }}
fetch-depth: 0 # Fetch all history to check if branch exists locally
- name: Check if branch exists locally
run: |
if [ ! -d "$(git rev-parse --show-toplevel)/.git/refs/heads/${{ env.BRANCH_NAME }}" ]; then
echo "Branch does not exist locally. Fetching from remote..."
git fetch origin pull/${{ github.event.number }}/head:${{ env.BRANCH_NAME }}
else
echo "Fetched remote branch."
fi
- name: Checkout
uses: actions/checkout@v3
with:
ref: ${{ env.BRANCH_NAME }}
- 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
run: |
cd marketplace && npm install && npm run build --workspaces
- name: Build marketplace plugins
run: |
cd marketplace && AWS_BUCKET=tooljet-plugins-stage node scripts/upload-to-s3.js
- name: Comment deployment URL
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Marketplace Plugin added to stage bucket'
})
- 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']
})
deploy-marketplace-plugin-remote:
if: ${{ github.event.action == 'labeled' && github.event.label.name == 'deploy-marketplace-plugin-remote' }}
runs-on: ubuntu-latest
steps:
- 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: sync repo
uses: actions@checkout@v3
- name: Fetch the remote branch
run: |
git fetch origin pull/${{ github.event.number }}/head:${{ env.BRANCH_NAME }}
- name: Checkout
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: Install and build dependencies
run: |
cd marketplace && npm install && npm run build --workspaces
- name: Build marketplace plugins
run: |
cd marketplace && AWS_BUCKET=tooljet-plugins-stage node scripts/upload-to-s3.js
- name: Comment deployment URL
uses: actions/github-script@v5
with:
github-token: ${{secrets.GITHUB_TOKEN}}
script: |
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: 'Marketplace Plugin added to stage bucket'
})
- 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']
})