Robert Schaap

Blogging like it’s 1999

Hello Godot!

Automating your Godot project’s build and deployment process can save you time and ensure your game is always up-to-date. In this quick write-up, I’ll walk you through how I set up CI/CD for a Godot 4.3 project with a Web export target. Using GitHub Actions, I automated the build process and deployed to an Azure Storage Container that makes it available as a static web site. Making it easy to share and test the latest version of my project. This setup is especially convenient for collaboration, every time someone pushes to the main branch or creates a pull request, a new build is automatically deployed. This way, collaborators can quickly review the latest changes or test the game without needing to build it locally.

Hello Godot!

Breaking down the workflow

  • Triggering the workflow: The workflow is triggered on pushes, as well as manually via workflow_dispatch. You can also set it up to deploy on pull requests which is convenient for reviewing.

  • Setting up the build environment: We use a Docker container with Godot pre-installed barichello/godot-ci:4.3. This container also supports direct upload to itch.io and other export targets.

  • Checking out the code: The actions/checkout@v4 action is used to check out the repository.

  • Setting up export templates: We move the Godot export templates to the correct directory.

  • Building the project: The project is built for the web platform. Use --headless to run without the GUI. Use --verbose to make sure there is enough information when something goes wrong.

  • Installing AzCopy: AzCopy is installed to facilitate the deployment to Azure Blob Storage.

  • Deploying the build: The built project is synced to Azure Blob Storage using AzCopy and a SAS URL stored in GitHub Secrets. See Azure static website for more information on hosting a static web site on Azure.

Here’s the YAML configuration I used to set up CI/CD for my Godot project:

name: Deploy to Web
on:
  push:
    branches: [ "main" ]
  workflow_dispatch:
env:
  GODOT_VERSION: 4.3
jobs:
  build:
    runs-on: ubuntu-latest
    container:
      image: barichello/godot-ci:4.3
    steps:
      - uses: actions/checkout@v4
      - name: Setup
        run: |
          mkdir -v -p ~/.local/share/godot/export_templates/
          mv /root/.local/share/godot/export_templates/${GODOT_VERSION}.stable \
            ~/.local/share/godot/export_templates/${GODOT_VERSION}.stable
      - name: Web Build
        run: |
          mkdir -v -p build/web
          godot --headless --verbose --export-release "Web" "build/web/index.html"
      - name: Install AzCopy
        run: |
          wget -O azcopy_v10.tar.gz https://aka.ms/downloadazcopy-v10-linux \
            && tar -xf azcopy_v10.tar.gz --strip-components=1
      - name: Deploy
        run: |
          ./azcopy sync "build/web" "${{ secrets.SAS_URL }}"

Conclusion

With this setup, every time you push changes to the main branch, your Godot project will be automatically built and deployed. This not only saves time but also ensures that your game is always up-to-date with the latest changes.

The GitHub repository is here:

https://github.com/rejschaap/hello-godot

You can find the hosted Godot project here:

https://www.schaap.io/hello-godot/index.html

Feel free to adapt this setup to your own project and storage solution.

Happy coding!