GitHub Actions
You can leverage the Juno CLI to perform tasks within GitHub Actions.
This guide will show you how to use the junobuild/juno-action to deploy your frontend assets, build and publish serverless functions, and optionally upgrade your WASM container.
1. Add a Secret Token for Automation
Before you can effectively implement automation, it is necessary to add a secret token to your GitHub repository or organization. This token will enable the CI (Continuous Integration) to interact with your satellite.
Follow the steps below to generate a new controller:
- Go to the Juno's console.
- Select your satellite.
- On the satellite's dashboard, navigate to the "Setup" tab.
- Click on "Add an access key".
- Generate a new key (default option) and assign it an appropriate role based on your workflow. Learn more about the available roles and their permissions to choose the appropriate level of access for your use case.
- Click "Submit".
- Upon successful creation, a new access key will be generated, and a "Secret token" will be displayed. Copy the token value and save it as an encrypted secret in your repository or organization, using the key
JUNO_TOKEN
.
2. Configure your project
If you already have a juno.config
file at the root of your project, you can skip to the next chapter. Otherwise, you need to create one manually or by running:
npx @junobuild/cli init --minimal
The configuration file can be a TypeScript, JavaScript, or JSON file (juno.config.ts
, juno.config.js|.mjs
, or juno.config.json
), depending on your preference.
At a minimum, the configuration file must include the following:
- Satellite ID: A unique identifier for your satellite.
- Source: The directory containing the built assets for your satellite. This is typically the output folder of your build process, generated after running a command like
npm run build
.
Satellite ID
Your Satellite ID can be found in the 'Overview' tab.
Source
Commonly, or if you are using the templates, these are the folders that can be set as the source
field:
Framework | Source |
---|---|
Next.js | out |
React, Astro, or Vue | dist |
SvelteKit | build |
Angular | dist/<your-project-name>/browser |
Configuration File Example
Here’s an example of configuration file:
import { defineConfig } from "@junobuild/config";
export default defineConfig({
satellite: {
ids: {
production: "qsgjb-riaaa-aaaaa-aaaga-cai" // Replace with your satellite ID
},
source: "dist", // Replace with your build output directory
predeploy: ["npm run build"] // Adjust based on your package manager
}
});
For detailed information about all available configuration options, refer to the configuration section.
3. Create the GitHub Action
You can use GitHub Actions to automate different parts of your Juno deployment workflow:
- 🪄 Deploy frontend assets to your Satellite. Learn how.
- 🛠️ Build and publish serverless functions (TypeScript or Rust). Learn how.
- ⚠️ Optionally upgrade your Satellite's WASM container. Learn how.
Each task can be performed independently or combined, depending on your project setup.
Environment Variables
When using the Actions, you can configure the following environment variables:
Environment Variable | Mandatory | Description |
---|---|---|
JUNO_TOKEN | Yes | The token to use for authentication. It can be generated through Juno's Console. Prefer a controller with "Read-write" permission rather than administrator. |
PROJECT_PATH | No | The path to the folder containing the juno.config file if it doesn't exist at the root of your repository. e.g. ./my-app-subfolder . |