Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
on:
push:
branches:
- main
jobs:
build:
permissions:
packages: write
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Use lowercase repository name as docker image name
run: echo "DOCKER_IMAGE_NAME=$(echo '${{ github.repository }}' | tr '[:upper:]' '[:lower:]')" >> "$GITHUB_ENV"

- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ github.token }}

- name: Build and push Docker image
uses: docker/build-push-action@v5
with:
push: true
tags: ghcr.io/${{ env.DOCKER_IMAGE_NAME }}:latest
33 changes: 33 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# The "display name", shown in the GitHub UI
name: Build and test

# Trigger, run on push on any branch
on:
pull_request:

jobs:
test:
runs-on: 'ubuntu-latest'
steps:
- uses: actions/checkout@v4
- name: Setup go
uses: actions/setup-go@v5
with: # Specify input variables to the action
go-version: '1.21.x'

#- run: echo "Hello world"
#- run: go version

- name: Build
run: go build -v ./...

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

lint:
runs-on: 'ubuntu-latest'
steps:
- name: Verify formatting
run: |
no_unformatted_files="$(gofmt -l $(git ls-files '*.go') | wc -l)"
exit "$no_unformatted_files"
1 change: 1 addition & 0 deletions cmd/api/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ func helloHandler(w http.ResponseWriter, r *http.Request) {
}
}


func rootHandler(w http.ResponseWriter, r *http.Request) {
fmt.Printf("got request to %s\n", r.URL.Path)
io.WriteString(w, "Hello world\n")
Expand Down