See the compiled result of this repository at www.TwinePractice.ElleYnn.com.
This repo demonstrates compiling multiple Twine files in the src
directory of the main
branch and deploying the HTML file to a custom domain (or a GitHub Page) via a GitHub Actions workflow.
Using GitHub Actions for compiling Twine games offers several benefits: it ensures a consistent and clean build environment, automates the compilation process for efficiency, facilitates seamless collaboration by handling merging and build processes, keeps the repository tidy by excluding compiled files, enables immediate detection of integration issues, and allows for secure handling of sensitive information through secrets. This automated workflow is scalable, supports continuous integration and delivery, and is adaptable to the growing complexity of game development.
A large part of this project takes inspiration from Em Lazer-Walker's 'A Modern Developer's Workflow For Twine' and 6note's TweeExample repository. Certain portions of these examples have depreciated since their publication, so I have created an alternative workflow that does not use the Go Environment since Tweego does not currently support Go modules. Instead, this workflow uses jq for JSON processing and the GitHub API to grab the latest precompiled version of Tweego.
Before using the provided build.yaml
file, make sure your GitHub Actions are configured with the appropriate permissions:
- Navigate to your repository on GitHub.
- Go to
Settings
>Actions
>General
. - Under Workflow permissions, make sure the following are set:
- Turn on 'Allow GitHub Actions to create and approve pull requests'.
- Select the 'Read and write permissions' option.
Set up the necessary repository variables for your GitHub Actions workflow:
- Go to your repository's
Settings
>Secrets and variables
>Actions
. - Create the following repository variables:
OUTPUT_DIRECTORY
: Set this todist
(or your preferred output directory for the compiled game).OUTPUT_FILENAME
: Set this toindex.html
(or your preferred name for the compiled game file).
Create a GitHub Personal Access Token (PAT) to allow your workflow to authenticate with the GitHub API:
- Visit GitHub Personal Access Tokens page and log in to your account.
- Click
Generate new token
. - Provide a descriptive name for your token.
- Under scopes, select
public_repo
if your repository is public. Adjust scopes as needed for private repositories. - Click
Generate token
. - Copy the generated token.
Add your GitHub Personal Access Token to your repository secrets:
- Go to your repository's
Settings
>Secrets and variables
>Actions
. - Click
New repository secret
. - Name the secret
PERSONAL_TOKEN
and paste your PAT into the value field. - Click
Add secret
.
Adjust the build.yaml
file as needed. Set the cname
field to your custom domain if applicable, or remove the line if not using a custom domain.
Once set up, any push to the main
branch will trigger the build and deployment of your project. Your game will be built using the latest version of Tweego and published to GitHub Pages.
If you encounter any issues or need further assistance, please refer to the GitHub Actions documentation or raise an issue in this repository.