GitHub Actions
Getting started
Section titled “Getting started”Check out this quick guide. I recommend testing with a public repository as you go along with the guide. It’s very fast! ⚡️
Basics
Section titled “Basics”- It’s a good idea to install this VSCode extension. At the very least, it can help lint the YAML files you write.
- You can test actions locally by using act, which essentially just uses the Docker API to do everything that GitHub would (but on your machine).
Manually running a workflow
Section titled “Manually running a workflow”- When authoring a workflow, consider using
workflow_dispatch
, which lets you manually trigger the workflow rather than waiting for an event like a push (reference, YAML reference):
on: push: branches: [main]
# Allow manual triggering. Just leave this blank if you have no inputs. workflow_dispatch:
- Note that you don’t need the YML file to specify
contents: write
; it’s your user that needs write permissions. So if you don’t have the “Run workflow” button after addingworkflow_dispatch
, make sure you’re logged in as an admin of the repo.
Reference links
Section titled “Reference links”- All Docker-related GitHub actions: https://docs.docker.com/build/ci/github-actions/
- Workflows that I’ve written for my bot
Finding a usable tag from an action in the marketplace
Section titled “Finding a usable tag from an action in the marketplace”Suppose you’re on a page like this: https://github.com/docker/login-action. You may see a “View on Marketplace” button:
Clicking that will bring you to a page with a version selector at the upper right which you can use to see which tags are available:
Alternatively, you can just go to the Releases page and click “Tags” on it, which results in a URL like this: https://github.com/docker/login-action/tags
Troubleshooting
Section titled “Troubleshooting”Can’t build a Docker image through GitHub actions
Section titled “Can’t build a Docker image through GitHub actions”If you can build locally, then perhaps you should try cloning the repo and trying to build in that fresh clone. It’s possible that a COPY . .
command doesn’t have the same source to copy from.