Set Up GitHub Actions

To enable a GitHub Actions workflow to perform actions on a Wix site, the workflow must set up and authenticate the Wix CLI using an API key. This allows you to automate tasks like creating preview deployments and publishing site updates directly from your GitHub repository.

Follow the steps below to set up GitHub Actions with the Wix CLI.

Prerequisites

Before setting up GitHub Actions, ensure you have:

  • A Wix site connected to GitHub
  • Admin access to your Wix account (required for API key generation)
  • Admin access to the GitHub repository

Note: You can also set up Git Integration & Wix CLI locally for testing.

Step 1 | Generate an API key

An API key allows GitHub Actions to authenticate with your Wix account and perform CLI operations on your sites.

To generate an API key:

  1. Go to the API Keys Manager
  2. Click Generate API Key
  3. Select the Wix CLI - Git Integration permission
  4. Copy and securely store the generated key

Important: Keep your API key secure and never commit it directly to your repository.

Step 2 | Store the API key as a GitHub secret

Visit the site's GitHub repo and create a repository secret to store the API key. This makes your API key available to use securely in the repo's GitHub Actions workflows.

Step 3 | Set up the CLI in the GitHub Actions workflow

Configure the GitHub Actions workflow to set up and authenticate the Wix CLI:

  1. In the GitHub Actions workflow, set up the Wix CLI by including the following command:

    Copy
  2. Next, authenticate it by including the following command:

    Copy

Step 4 | Include CLI commands

The workflow can now run authenticated Wix CLI commands to interact with the site. For example:

  • Include npm run wix preview in the workflow to build a preview version of the site based on the current branch. You can set up a workflow to create a preview version whenever a new PR is created.
  • Include npm run wix publish in the workflow to publish the site based on the repo's default branch. You can set up a workflow whenever a PR is merged to the default branch.

See also

Did this help?