Skip to main content

Common Workflow Examples

We use the placeholder name contoso for a username; replace it with your own username before using these workflows.

Run tests for a Go project on every commit and PR

name: Tests

"on":
push:
branches:
- main
pull_request:

jobs:
test:
name: Test
runs-on: ubuntu-22.04
steps:
- uses: actions/checkout@v4

- name: Set up Go
uses: actions/setup-go@v5
with:
go-version: 1.23

- name: Lint
uses: https://github.com/golangci/golangci-lint-action@v6
with:
version: v1.62
args: --timeout=5m --verbose

- name: Get deps
run: go get .

- name: Build and Test
run: go test ./...

Build and push a Docker container to Worktree Packages

This requires setting a secret called WORKTREE_ACCESS_TOKEN with a Personal Access Token for your account with read-write access to Packages.

name: Container

"on":
push:
branches:
- main

jobs:
release-image:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Login to Worktree Packages
uses: https://github.com/docker/login-action@v3
with:
registry: worktree.ca
username: contoso
password: ${{ secrets.WORKTREE_ACCESS_TOKEN }}

- name: Build and push
uses: https://github.com/docker/build-push-action@v5
with:
context: .
file: ./Dockerfile
push: true
tags: |
worktree.ca/contoso/mycontainer:${{ env.GITHUB_REF_NAME }}
worktree.ca/contoso/mycontainer:latest