To run the GitHub Actions workflows locally using the act utility, you can follow these steps:
You can install act using Homebrew on macOS, or download it directly for other platforms.
brew install act
Or download it from the GitHub releases page.
act allows you to simulate the GitHub Actions environment and execute the workflows as if they were running on GitHub.
Note - for the following commands, it is assumed you are in the base directory of the repository - and have the following environment variables set:
GH_USER
- set to your github user name (such as josephbarnett)GH_PAT
- set to your github personal access token. This token should have repo write permissions, and package write permissions
Now, you can run the following workflow simulations.
The manual merge workflow release-to-main.yml will perform a sync merge from the develop
branch to main
.
All releases are based on main
, where as develop
is incrementally changing until we are ready to release.
To manual trigger the workflow, use the following command:
act --container-architecture linux/arm64 \
-a $GH_USER --secret GITHUB_TOKEN=$GH_PAT \
-j release-to-main
For the DockerBuild workflow docker-build.yml, simulate a push to the main branch, develop branch, and a new release tag. It will automatically build a docker image from the repository code, scan it for security vulnerabilties, then if on main or develop - will publish the docker image to the public GHCR repository associated with the repository.
The following sub-sections allow you to simulate these events and run each permuation.
Don't forget to update the
.json
file first before running the command!
act --container-architecture linux/arm64 \
-a $GH_USER --secret GITHUB_TOKEN=$GH_PAT \
-j docker --eventpath .github/workflows/events/develop-push-event.json
Don't forget to update the
.json
file first!
act --container-architecture linux/arm64 \
-a $GH_USER --secret GITHUB_TOKEN=$GH_PAT \
-j docker --eventpath .github/workflows/events/main-push-event.json
Don't forget to update the
.json
file first!
act --container-architecture linux/arm64 \
-a $GH_USER --secret GITHUB_TOKEN=$GH_PAT \
-j docker --eventpath .github/workflows/events/release-event.json
By using these commands, you can test your workflows locally and verify their functionality before pushing them to GitHub. This ensures that your workflows are working correctly without needing to trigger them on the actual repository.