Deploy Static Sites with GitHub Actions on Nife | Site CI/CD Integration
Learn to deploy static sites using GitHub Actions with Nife. Automatically deploy your site on every push to GitHub.
Continuous Deployment Using Nifectl (CLI) with GitHubβ
Prerequisitesβ
- Your site code is available on GitHub
- You have a Nife account
- You have deployed your site to Nife at least once
Step-by-Step Setupβ
1. Get Your Nife API Tokenβ
Retrieve your Nife API token using one of these methods:
Option A: Using nifectl CLI
nifectl auth token
Option B: From Nife Dashboard
- Log in to launch.nife.io
- Go to Settings β API Tokens
- Generate a new token
2. Create GitHub Secretβ
- Go to your GitHub repository
- Click Settings
- Navigate to Secrets and variables β Actions
- Click New repository secret
- Name:
NIFE_ACCESS_TOKEN - Value: Paste your Nife API token from Step 1
- Click Add secret
3. Create GitHub Actions Workflowβ
Clone your repository to your local machine:
git clone https://github.com/your-org/your-repo.git
cd your-repo
Create the GitHub Actions workflow file:
mkdir -p .github/workflows
Create .github/workflows/main.yml with these contents:
name: Deploy Site to Nife
on:
push:
branches:
- main
- master
jobs:
deploy:
name: Deploy to Nife
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Deploy to Nife
env:
NIFE_ACCESS_TOKEN: ${{ secrets.NIFE_ACCESS_TOKEN }}
with:
args: "site redeploy --yes"
4. Commit and Pushβ
git add .github/workflows/main.yml
git commit -m "Add Nife site deployment workflow"
git push
5. Monitor Deploymentβ
- Go to your GitHub repository
- Click Actions tab
- Watch your workflow run in real-time
- See the deployment logs
Your site will now deploy automatically on every push to main or master branches.
Continuous Deployment Using Nife Dashboard UI with GitHubβ
Prerequisitesβ
- Your site is deployed on Nife
- You have admin access to your GitHub repository
Step-by-Step Setupβ
1. Deploy Your Site to Nifeβ
First, deploy your static site to Nife:
- Log in to launch.nife.io
- Click Create New Site
- Provide your GitHub repository URL
- Configure build settings:
- Install Command:
npm install(or your build tool) - Build Command:
npm run build(or your build command) - Output Directory:
build,dist, orpublic(where your built files are)
- Install Command:
- Click Deploy
Your site is now live on Nife.
2. Download nife.toml Configurationβ
After deployment, download your site's configuration:
- Go to your Site in the Nife Dashboard
- Click Settings or Configuration
- Click Download nife.toml
This downloads your site's configuration file.
3. Configure nife.toml with Git URLβ
The downloaded nife.toml file contains your site configuration. You need to add your GitHub repository URL so Nife knows where to pull your code from automatically.
Example nife.toml:
name = "my-awesome-site"
org = "your-org-id"
git-url = "https://github.com/your-org/your-repo"
git-branch = "main"
git-provider = "github"
framework = "React"
install = "npm install"
build = "npm run build"
output = "build"
Key fields to set:
git-url- Your GitHub repository URL (e.g.,https://github.com/username/my-site) - This automatically updates when you push!git-branch- Branch to deploy from (default:main)install- Command to install dependencies (e.g.,npm install)build- Command to build your site (e.g.,npm run build)output- Directory with built files (e.g.,dist,build,public)
The Git URL field is crucialβit tells Nife where to fetch your code from automatically on every deployment.
4. Add nife.toml to Repositoryβ
- Copy the
nife.tomlfile to your repository root - Commit and push it:
git add nife.toml
git commit -m "Add Nife site configuration"
git push
5. Generate Nife API Tokenβ
- Log in to launch.nife.io
- Go to Settings β API Tokens
- Click Generate New Token
- Select expiry duration:
- 1 Hour - For testing
- Lifetime - For permanent use
- Click Generate
- Copy the token
6. Add Token to GitHub Secretsβ
- Go to your GitHub repository
- Click Settings
- Navigate to Secrets and variables β Actions
- Click New repository secret
- Name:
NIFE_ACCESS_TOKEN - Value: Paste your Nife API token
- Click Add secret
7. Set Up CI/CD Integrationβ
- In your Site in Nife Dashboard
- Look for Setup GitHub CI/CD button
- Click it to see the guided setup
- Follow the 3-step configuration:
- Step 1: Configure Workflow
- Step 2: Download nife.toml
- Step 3: Add Access Token
This pushes the GitHub Actions workflow to your repository.
8. Monitor Deploymentsβ
- Go to your GitHub repository
- Click Actions tab
- View workflow runs and logs
- Your site deploys automatically on every push
Supported Frameworksβ
The Nife static site deployment supports any framework that produces static HTML, CSS, and JavaScript:
- React - Build with
npm run build - Vue - Build with
npm run build - Next.js - Build with
npm run build - Astro - Build with
npm run build - Jekyll - Build with
jekyll build - Hugo - Build with
hugo - Gatsby - Build with
gatsby build - Eleventy - Build with
eleventy - Svelte - Build with
npm run build - Static HTML - No build needed
As long as your framework produces static files in an output directory, it works with Nife.
Workflow Explanationβ
Here's what happens when you push code:
1. You push to GitHub (main/master branch)
β
2. GitHub Actions workflow triggers
β
3. Checkout your repository code
β
4. Execute "site redeploy --yes" command
β
5. Nife reads nife.toml configuration
β
6. Pulls latest code from GitHub using git-url
β
7. Runs build command (npm run build, etc.)
β
8. Deploys built files to Nife
β
9. Site is live with your changes
The --yes flag automatically confirms the deployment without waiting for user inputβperfect for CI/CD automation.
Troubleshootingβ
Workflow doesn't triggerβ
- Verify
.github/workflows/deploy-site.ymlexists - Check that file is committed and pushed to GitHub
- Ensure workflow is on correct branch (
mainormaster)
"NIFE_ACCESS_TOKEN not found" errorβ
- Go to GitHub Settings β Secrets and verify token exists
- If missing, add it again from your Nife Dashboard token
- Make sure secret name is exactly
NIFE_ACCESS_TOKEN
"Site not found" errorβ
- Verify site exists in Nife Dashboard
- Check
nife.tomlis in repository root - Ensure
git-urlin nife.toml points to correct GitHub repository - Verify site name in
nife.tomlmatches Nife Dashboard
Deployment timeoutβ
- Check if site is very large
- Increase timeout in workflow:
timeout-minutes: 15 - Review GitHub Actions logs for specific errors
Site doesn't update after pushβ
- Verify
git-urlin nife.toml is correct - Check that
git-branchmatches your push branch - Ensure build commands work locally:
npm run build - Check GitHub Actions logs for build errors
Best Practicesβ
β
Keep nife.toml in Git - Version control your deployment configuration
β
Use meaningful commit messages - Track what changed in each deployment
β
Test locally first - Run build command locally before pushing
β
Protect main branch - Require reviews before merging
β
Monitor deployments - Check Actions tab after pushing
β
Regenerate tokens periodically - Update tokens every 30-60 days
β
Use specific build commands - Ensure your build command produces correct output
β
Verify output directory - Make sure output field matches your build output folder
Environment Variablesβ
If your build process needs environment variables, you can add them to GitHub Secrets:
- Go to GitHub repository Settings
- Secrets and variables β Actions
- Add variables like
REACT_APP_API_URL, etc. - Reference in your code normally
The workflow automatically includes all secrets as environment variables.
More Resourcesβ
- Find Nife Actions on GitHub Marketplace
- GitHub Actions Documentation
- Nife Documentation
- Nife CLI Site Reference
Β© Nife - Deploy anything, anywhere