Automatic Deploy with GitHub Actions
Learn how to set up automatic deploy on Zenifra using GitHub Actions. Complete CI/CD for automatic updates.
First Step
To automatically update your project code on Zenifra using GitHub Actions, you need to have a Git repository configured with your application's source code.
This feature allows the OCI image to be built and pushed to Zenifra automatically whenever there is a new change in the repository, through a workflow.
For this, the ramonpaolo/action-zenifra action will be used, which is responsible for integrating the automatic build and deployment process with the Zenifra platform.
Second Step
To set up the automatic update, follow the steps below:
Workflow Configuration
You will need to create a workflow file in the .github/workflows/ directory of your Git repository.
Example of a complete workflow using the ramonpaolo/action-zenifra action:
name: Deploy PRD
on:
push:
tags:
- 'v[0-9]+.[0-9]+.[0-9]+'
jobs:
build: # Job to build and publish the OCI image
name: build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Set up QEMU
uses: docker/setup-qemu-action@v2
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Log in to OCI Registry
uses: docker/login-action@v2
with:
username: ${{ secrets.OCI_USERNAME }}
password: ${{ secrets.OCI_PASSWORD }}
- name: Build and Publish OCI Image
run: buildx build -t <username>/<name_image>:<tag> --platform=linux/amd64 --push .
deploy: # Job to deploy the OCI image on Zenifra
needs: build
name: deploy
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@main
- name: Deploy Image to Zenifra
uses: ramonpaolo/action-zenifra@main
with:
PROJECT_ID: <project_id> # ${{ secrets.ZENIFRA_PROJECT_ID }}
API_KEY: <api_key> # ${{ secrets.ZENIFRA_API_KEY }}
IMAGE: <username>/<name_image>:<tag> # <username>/<name_image>:${{ github.ref_name }}⚠️ Important: Replace
project-idwith your project ID,API_KEYwith your project's API key, andimagewith the full image URI.
Configuration Details
PROJECT_ID: The project ID on Zenifra. Should be stored as a secret in your repository.API_KEY: The API key for your project on Zenifra. Should be stored as a secret in your repository.IMAGE: The OCI image URI to be sent, including the registry and tag.
Third Step
After creating and committing the workflow file, every time a tag in the format vX.X.X (e.g. v1.X.X) is created, GitHub Actions will:
- Check out the code;
- Build the image in OCI format using build tools;
- Push the updated image to Zenifra using the
ramonpaolo/action-zenifraaction.
This ensures that your project always runs the latest version of your application without manual intervention.
Wrapping Up
With this workflow configured, your application will always be updated according to changes made in the Git repository, keeping your project up-to-date with the latest code version.
If you want to further customize the workflow, you can add steps such as automated testing, validation checks, or even deployment to multiple environments.
How to Create a Project on Zenifra via Console
Learn how to create your first project on the Zenifra platform. Complete tutorial with console, plans, settings and cloud deployment.
How to Change Project Settings
Learn how to change your project settings on Zenifra via console. Name, description, image, ENVs, instances and more.