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 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'] })