Perform certain operations on a Cloudways server via the Cloudways API. Please note that not all API operations are permitted.
| Operation | Key | Parameters |
|---|---|---|
| Change service state | service |
service: mysql, apache2, nginx, memcached, varnish, redis-server, php*.*-fpm (e.g. php8.0-fpm), elasticsearch, supervisor state: start, stop, restart |
| Update server varnish state | varnish |
action: enable, disable, purge |
| Purge Assets from Cloudways CDN | cdn_purge |
app_id |
Cloudways account email
Cloudways API key. See https://platform.cloudways.com/api
Numeric ID of the server, can be found in the URL of web panel e.g.: platform.cloudways.com/server/server-id/access_detail
Operations are specified with a dot notation and should include each parameter. Order matters, use the same order as specified above. E.g. service.mysql.restart or cdn_purge.12345 (where 12345 represents the app_id).
The safest way to pass credentials to this action is via Github Secrets. See https://docs.github.com/en/actions/security-guides/encrypted-secrets#using-encrypted-secrets-in-a-workflow
name: Clear Server Varnish Cache
on: [push]
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Build
...
- name: Deploy
...
- name: Purge Varnish
uses: shamoon/cloudways-operations@main
with:
email: ${{ secrets.CLOUDWAYS_EMAIL }}
api-key: ${{ secrets.CLOUDWAYS_API_KEY }}
server-id: ${{ secrets.CLOUDWAYS_SERVER_ID }}
operation: varnish.purgeThis can break things, be careful