GitHub Action
You can use our CLI inside a GitHub action as any other tool CLI tool.
We also provide our own GitHub Action, it's available for free in GitHub's marketplace.
Let's understand how you can use our GitHub Action to deploy your app.
Deploying using our GitHub Action
Let's suppose you have a Mono Repo with two apps: my-app
(code in the folder my-app
inside the mono repo root folder) and another-app
(code in the folder another-app
inside the mono repo root folder).
Then you want to deploy my-app
only when you have changes at my-app
folder in the main
branch.
Here is how you would use our GitHub Action, create a yaml file at .github/workflows/zcloud-deploy-my-app.yml
with the following content:
name: Docs Deploy
on:
push:
branches: ['main']
paths: ['my-app/**', '.github/workflows/zcloud-deploy-my-app.yml']
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy
uses: zcloud-ws/zcloud-deploy-action@main
with:
user-token: ${{ secrets.ZCLOUD_USER_TOKEN }}
env: "customer-my-app"
dir: "docs/"
Configurations:
- env: In Quave Cloud web app you get this value in the
Settings
tab of your app environment (Environment Name
). - dir: the directory that you want to provide as the root directory of your app.
- user-token: In Quave Cloud web app you get this token for your user at app.quave.cloud/profile. We recommend you to create a secret in your GitHub project under
Settings > Security section > Secrets and variables > Actions
calledZCLOUD_USER_TOKEN
. - env-token: In Quave Cloud web app you get this token for your env at its settings tab. We recommend you to create a secret in your GitHub project under
Settings > Security section > Secrets and variables > Actions
calledZCLOUD_ENV_TOKEN
. - cli-extra-args: You can provide any extra arguments that you want to pass to our CLI. For example, if you want to pass
--env-var X=1 --env-var Y=1
you can do it like this:cli-extra-args: "--env-var X=1 --env-var Y=1"
You can also use
env-token
: In Quave Cloud web app you get this token for your app env at its settings tab. We recommend you to create a secret in your GitHub project underSettings > Security section > Secrets and variables > Actions
calledZCLOUD_ENV_TOKEN
.
That done, now your pushes to main will trigger a deployment of my-app
only when you make changes to my-app
folder.
This example uses mono repo as it is a more complex set up, but you can use our GitHub action to deploy any app.
Fun fact: we use our GitHub Action to deploy our docs to Quave Cloud (yes, this website you are reading right now) with this exact same config explained above.
Deploying after running tests
It's very common to want to run tests before deploying your app. For example, you might want to run tests before deploying to make sure your app is working as expected.
Also, it's common to need to install some dependencies before running tests. For example, you might want to install Meteor before running tests to use Meteor binary to run the tests.
In the example below you can see how you can do that.
name: Deploy
on:
push:
branches: ['main']
jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Install Node.js
uses: actions/setup-node@v4
with:
node-version: '20.x'
- name: Install Dependencies
run: |
curl https://install.meteor.com | /bin/sh && meteor npm i
- name: Run Check
run: |
meteor npm run quave-check
- name: Run Tests
run: |
meteor npm run test
deploy:
needs: test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Deploy App
uses: zcloud-ws/zcloud-deploy-action@main
with:
user-token: ${{ secrets.ZCLOUD_USER_TOKEN }}
env: "your-env-name"
Deploy using our CLI
If you want to use our CLI directly from a GitHub action instead of using our GitHub Action you can do it like this:
name: CLI Deploy
on:
push:
branches: ['main']
paths: ['my-app/**', '.github/workflows/zcloud-deploy-my-app.yml']
jobs:
deploy:
runs-on: ubuntu-latest
container:
image: zcloudws/zcloud-cli
env:
ZCLOUD_USER_TOKEN: ${{ secrets.ZCLOUD_USER_TOKEN }}
steps:
- uses: actions/checkout@v4
- name: Deploy with Quave Cloud CLI
env:
ZCLOUD_USER_TOKEN: ${{ secrets.ZCLOUD_USER_TOKEN }}
run: zcloud deploy --env "customer-my-app" --dir "docs"
Both are going to result in the same deploy command being triggered by our CLI.