Skip to main content

Documentation Index

Fetch the complete documentation index at: https://docs.bunny.net/llms.txt

Use this file to discover all available pages before exploring further.

Automate your deployments by integrating Magic Containers with GitHub Actions. When you push changes to your repository, your workflow can build a Docker image, push it to a container registry, and trigger a rolling update on Magic Containers.

Prerequisites

  • An application already deployed on the Magic Containers platform
  • A GitHub repository containing a Dockerfile or valid build context
  • Container registry credentials (use GITHUB_TOKEN for GitHub Container Registry, or personal access tokens for DockerHub)

Quickstart

Add a step to your GitHub Actions workflow with the following inputs: app_id, api_key, container, and image_tag. This triggers a rolling update whenever a new image is built and pushed.
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

InputRequiredDescription
app_idYesThe App ID for your Magic Containers application
api_keyYesThe API Key for your Bunny account (sub-user accounts not supported)
containerYesThe name of the container within the application
image_tagYesThe new image tag