Skip to content

Workflow branch #25

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
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
Loading