GitHub Action
This GitHub Action provides an automated way to update container images on Magic Containers, enabling the building and pushing of new container images without manual intervention. When integrated into your GitHub workflow, the process includes building a Docker image, pushing the image to a container registry such as GitHub Container Registry or DockerHub, and updating your application on Magic Containers.
What you’ll need
Before you dive in, make sure you have the following prerequisites in place:
- An application already deployed on the Magic Containers platform.
- A GitHub repository containing a Dockerfile or another valid build context for containerization. Make sure you have the necessary container registry credentials. If you are using the GitHub Container Registry, you can rely on the GITHUB_TOKEN, while DockerHub may require personal access tokens or similar credentials.
Usage example
To use this action, add a step in your GitHub Actions workflow. The step must include four inputs: app_id
, api_key
, container
, and image_tag
. By configuring these inputs correctly, the action will automatically trigger a rolling update on your Magic Containers application whenever a new image is built and pushed.
The following workflow demonstrates how to build a Docker image, push it to the GitHub Container Registry, and then update the image on Magic Containers. Adjust the registry information, branch, and image tag format as needed.
name: Update container image when pushing to main
on:
push:
branches:
- 'main'
jobs:
build:
name: Build and deploy
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: docker login
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: docker build and push
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ghcr.io/${{ github.repository }}:${{ github.sha }}
- name: Update container image on Magic Containers
uses: BunnyWay/actions/container-update-image@main
with:
app_id: ${{ vars.APP_ID }}
api_key: ${{ secrets.BUNNYNET_API_KEY }}
container: app
image_tag: "${{ github.sha }}"
Inputs
Use the following inputs to configure the action:
app_id
(required): The App ID for your Magic Containers application.api_key
(required): The API Key for your Bunny account. Sub-user accounts are not supported at this time.container
(required): The name of the container within the Magic Containers application.image_tag
(required): The new image tag.
Need help or encountering issues?
If you encounter any difficulties or have questions while following this Quickstart Guide, our support team is here to assist you. Please don't hesitate to contact us via support request form for prompt assistance.
Our dedicated support team is ready to help you resolve any issues you might face during the deployment process, provide additional guidance, or answer your questions.
Updated about 23 hours ago