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.
Before setting up GitHub Actions, ensure you have:
Note: You can also set up Git Integration & Wix CLI locally for testing.
An API key allows GitHub Actions to authenticate with your Wix account and perform CLI operations on your sites.
To generate an API key:
Important: Keep your API key secure and never commit it directly to your repository.
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.
Configure the GitHub Actions workflow to set up and authenticate the Wix CLI:
In the GitHub Actions workflow, set up the Wix CLI by including the following command:
Next, authenticate it by including the following command:
The workflow can now run authenticated Wix CLI commands to interact with the site. For example:
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.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.