Skip to content

Commit 1115d52

Browse files
committed
Update the instwp deploy to only push a zip passed in via the dispatch
instawp api doesn't actually support pushing a file directly by curl, the zip needs to be publicly accessible - presumably because it uses wp-cli to install
1 parent 4433170 commit 1115d52

1 file changed

Lines changed: 33 additions & 51 deletions

File tree

Lines changed: 33 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,67 +1,49 @@
11
name: Deploy to InstaWP
22
on:
3-
release:
4-
types: [published]
53
workflow_dispatch:
4+
inputs:
5+
plugin_zip_path:
6+
description: 'Path to the plugin zip file to deploy. Must be a zip file.'
7+
required: true
8+
type: string
69

710
jobs:
811
deploy:
912
runs-on: ubuntu-latest
1013

1114
steps:
12-
- name: Checkout Repository
13-
uses: actions/checkout@v4
14-
15-
- name: Set up PHP
16-
uses: shivammathur/setup-php@v2
17-
with:
18-
php-version: '8.2'
19-
tools: composer
20-
21-
- name: Set up Node.js
22-
uses: actions/setup-node@v4
23-
with:
24-
node-version: '20'
25-
26-
- name: Cache Composer dependencies
27-
uses: actions/cache@v4
28-
with:
29-
path: vendor
30-
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }}
31-
restore-keys: |
32-
${{ runner.os }}-composer-
33-
34-
- name: Cache NPM dependencies
35-
uses: actions/cache@v4
36-
with:
37-
path: node_modules
38-
key: ${{ runner.os }}-npm-${{ hashFiles('**/package-lock.json') }}
39-
restore-keys: |
40-
${{ runner.os }}-npm-
41-
42-
- name: Install Composer dependencies
43-
run: composer install --no-dev
44-
45-
- name: Install NPM dependencies
46-
run: npm install
47-
48-
- name: Build plugin zip
49-
run: npm run dist
50-
51-
- name: List files before deploy
15+
- name: Validate plugin zip file
16+
id: validate_zip
17+
run: |
18+
ZIP_PATH="${{ github.event.inputs.plugin_zip_path }}"
19+
if [ ! -f "$ZIP_PATH" ]; then
20+
echo "File does not exist: $ZIP_PATH"
21+
exit 1
22+
fi
23+
if [[ "$ZIP_PATH" != *.zip ]]; then
24+
echo "File does not have .zip extension: $ZIP_PATH"
25+
exit 1
26+
fi
27+
MIME_TYPE=$(file --mime-type -b "$ZIP_PATH")
28+
if [ "$MIME_TYPE" != "application/zip" ]; then
29+
echo "File is not a valid zip archive: $ZIP_PATH (type: $MIME_TYPE)"
30+
exit 1
31+
fi
32+
echo "ZIP_PATH=$ZIP_PATH" >> $GITHUB_ENV
33+
34+
- name: Upload plugin zip to transfer.sh
35+
id: upload_zip
5236
run: |
53-
echo "Current working directory:"
54-
pwd
55-
echo "Listing all files recursively:"
56-
find . -type f | sort
37+
UPLOAD_URL=$(curl --silent --upload-file "$ZIP_PATH" "https://transfer.sh/$(basename $ZIP_PATH)")
38+
echo "UPLOAD_URL=$UPLOAD_URL" >> $GITHUB_ENV
5739
5840
- name: Deploy to InstaWP
5941
run: |
6042
API_KEY=${{ secrets.INSTAWP_API_KEY }}
61-
PLUGIN_ZIP=$(ls dist/accessibility-checker-*.zip | head -n 1)
6243
SITE_ID=${{ secrets.INSTAWP_SITE_ID }}
63-
curl -X POST "https://api.instawp.io/v2/sites/install-plugin" \
44+
PLUGIN_URL="$UPLOAD_URL"
45+
curl -X PUT "https://app.instawp.io/api/v2/sites/$SITE_ID/install-content" \
6446
-H "Authorization: Bearer $API_KEY" \
65-
-H "Content-Type: multipart/form-data" \
66-
-F "file=@$PLUGIN_ZIP" \
67-
-F "site_id=$SITE_ID"
47+
-H "Accept: application/json" \
48+
-H "Content-Type: application/json" \
49+
-d "{\"plugin_urls\": \"$PLUGIN_URL\"}"

0 commit comments

Comments
 (0)