Skip to content

Deploy to InstaWP

Deploy to InstaWP #4

name: Deploy to InstaWP
on:
workflow_dispatch:
inputs:
plugin_zip_path:
description: 'Path to the plugin zip file to deploy. Must be a zip file.'
required: true
type: string
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Download and validate plugin zip file
id: validate_zip
run: |
ZIP_URL="${{ github.event.inputs.plugin_zip_path }}"
ZIP_NAME=$(basename "$ZIP_URL")
curl -L "$ZIP_URL" -o "$ZIP_NAME"
if [ ! -f "$ZIP_NAME" ]; then
echo "File does not exist: $ZIP_NAME"
exit 1
fi
if [[ "$ZIP_NAME" != *.zip ]]; then
echo "File does not have .zip extension: $ZIP_NAME"
exit 1
fi
MIME_TYPE=$(file --mime-type -b "$ZIP_NAME")
if [ "$MIME_TYPE" != "application/zip" ]; then
echo "File is not a valid zip archive: $ZIP_NAME (type: $MIME_TYPE)"
exit 1
fi
- name: Deploy to InstaWP
run: |
API_KEY=${{ secrets.INSTAWP_API_KEY }}
SITE_ID=${{ secrets.INSTAWP_SITE_ID }}
PLUGIN_URL="${{ github.event.inputs.plugin_zip_path }}"
curl -X PUT "https://app.instawp.io/api/v2/sites/$SITE_ID/install-content" \
-H "Authorization: Bearer $API_KEY" \
-H "Accept: application/json" \
-H "Content-Type: application/json" \
-d "{\"plugin_urls\": \"$PLUGIN_URL\"}"