Skip to content

build(deps): bump the npm-dependencies group with 59 updates #10

build(deps): bump the npm-dependencies group with 59 updates

build(deps): bump the npm-dependencies group with 59 updates #10

Workflow file for this run

name: Build a zip, Comment on PR & Delete a zip on closed
on:
pull_request:
types: [opened, synchronize, ready_for_review, closed, labeled]
branches:
- master
- dev
- next-release
- milestone
paths:
- "src/**"
- "includes/**"
- "ultimate-addons-for-gutenberg.php"
- "package.json"
- "package-lock.json"
- "webpack.config.js"
- ".github/workflows/build-a-zip.yml"
# Cancels all previous workflow runs for pull requests that have not completed.
concurrency:
# The concurrency group contains the workflow name and the branch name for pull requests
# or the commit hash for any other events.
group: ${{ github.workflow }}-${{ github.event_name == 'pull_request' && github.head_ref || github.sha }}
cancel-in-progress: true
env:
ZIP_URL: https://dev.ultimategutenberg.com/wp-content/uploads/uag-gh/
PLUGIN_SLUG: ${{ github.event.repository.name }}
ZIP_NAME: "${{ github.event.repository.name }}.zip"
jobs:
build-zip:
name: "Build a zip and upload to server"
if: ${{ github.event.action != 'closed' && github.event.label.name == 'create zip' }}
runs-on: ubuntu-latest
outputs:
branch_name: ${{ steps.get_current_branch.outputs.branch_name }}
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Use desired version of NodeJS
uses: actions/setup-node@v4
with:
node-version: '20'
cache: 'npm'
- name: Extract current branch name
id: get_current_branch
run: echo "branch_name=$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_OUTPUT
- name: Install dependencies
run: npm ci
- name: Create a build
run: npm run build
- name: Build a package
run: bash ./bin/build-zip.sh
- name: Create branch directory
run: |
cd artifact
mkdir -p ${{ steps.get_current_branch.outputs.branch_name }}
mv ${{ env.ZIP_NAME }} ${{ steps.get_current_branch.outputs.branch_name }}/
- name: Upload a zip to server
uses: burnett01/rsync-deployments@4.1
with:
# switches: -avzr --delete --delete-excluded --exclude-from=".distignore" --include="" --filter=""
switches: -avzr
path: ./artifact/
remote_path: ${{ secrets.SSH_ZIP_PATH }}
remote_host: ${{ secrets.SSH_HOST }}
remote_port: ${{ secrets.SSH_PORT }}
remote_user: ${{ secrets.SSH_USER }}
remote_key: ${{ secrets.SSH_KEY }}
comment-on-pr:
name: Comment on PR with links to plugin ZIPs
if: ${{ github.event.action != 'closed' && github.head_ref && github.head_ref != null && github.event.label.name == 'create zip' }}
runs-on: ubuntu-latest
needs: build-zip
env:
CI: true
GITHUB_TOKEN: ${{ secrets.BOT_TOKEN }}
outputs:
pr_number: ${{ steps.get_pr_number.outputs.pr_number }}
comment_body: ${{ steps.get_comment_body.outputs.body }}
steps:
- name: Get PR number
id: get_pr_number
run: echo "pr_number=${{ github.event.pull_request.number }}" >> $GITHUB_OUTPUT
- name: Get comment body
id: get_comment_body
run: |
body="Plugin zip for ${{ github.event.pull_request.head.sha }} is ready :bellhop_bell:!
- Download the plugin [zip](${{ env.ZIP_URL }}${{ needs.build-zip.outputs.branch_name }}/${{ env.ZIP_NAME }})"
body="${body//$'\n'/'%0A'}"
echo "body=$body" >> $GITHUB_OUTPUT
- name: Find an old comment if any
uses: sandeshjangam/comment-actions@v1
id: find_comment
with:
type: find
number: ${{ steps.get_pr_number.outputs.pr_number }}
search_term: Download the plugin [zip]
- name: Delete an old comment
if: ${{ steps.find_comment.outputs.comment_id != '' }}
uses: sandeshjangam/comment-actions@v1
with:
type: delete
comment_id: ${{ steps.find_comment.outputs.comment_id }}
- name: Create a new comment with a download link of plugin zip
uses: sandeshjangam/comment-actions@v1
with:
type: create
number: ${{ steps.get_pr_number.outputs.pr_number }}
body: ${{ steps.get_comment_body.outputs.body }}
reactions: hooray, heart, rocket
clean-zip:
name: "Clean a zip on server"
if: ${{ github.event.action == 'closed' }}
runs-on: ubuntu-latest
steps:
- name: "Checkout"
uses: actions/checkout@v4
- name: Extract current branch name
id: get_current_branch
run: |
echo "branch_name=$(REF=${GITHUB_HEAD_REF:-$GITHUB_REF} && echo ${REF#refs/heads/} | sed 's/\//-/g')" >> $GITHUB_OUTPUT
echo ${{ steps.get_current_branch.outputs.branch_name }}
- name: Execute a delete command using password
if: ${{ steps.get_current_branch.outputs.branch_name != '' }}
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.SSH_HOST }}
port: ${{ secrets.SSH_PORT }}
username: ${{ secrets.SSH_USER }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ${{ secrets.SSH_ZIP_PATH }}
rm -rf ${{ steps.get_current_branch.outputs.branch_name }}