Deploy to InstaWP #6
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 POST "https://app.instawp.io/api/v2/sites/$SITE_ID/execute-command" \ | |
| -H "Authorization: Bearer $API_KEY" \ | |
| -H "Accept: application/json" \ | |
| -H "Content-Type: application/json" \ | |
| -d "{ | |
| \"command_id\": 2623, | |
| \"commandArguments\": [ | |
| {\"PLUGIN_STRING\": \"$PLUGIN_URL\"} | |
| ] | |
| }" | |