Skip to content

Commit

Permalink
Remove CircleCI and use Github Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
recrsn committed Nov 20, 2023
1 parent edbbe9d commit 44644fb
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 17 deletions.
12 changes: 0 additions & 12 deletions .circleci/config.yml

This file was deleted.

42 changes: 42 additions & 0 deletions .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
on:
push:
branches:
- master
tags:
- v*
pull_request:
branches:
- master

jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Setup Go
uses: actions/setup-go@v2
with:
go-version: 1.21
- name: Build
run: |
mkdir -p ./coffee-beans
cp coffee-beans.yaml ./coffee-beans
go build -o ./coffee-beans/coffee-beans -ldflags "-X main.version=${GITHUB_REF#refs/*/}" "-X main.commit=${GITHUB_SHA}"
- name: Test
run: |
go test -v ./...
- name: Package
run: |
tar -czf coffee-beans.tar.gz ./coffee-beans
- name: Upload
if: github.ref == 'refs/heads/master' || github.ref == 'refs/tags/v*'
uses: actions/upload-artifact@v2
with:
name: coffee-beans
path: coffee-beans.tar.gz
- name: Release
uses: softprops/action-gh-release@v1
if: github.ref == 'refs/tags/v*'
with:
files: coffee-beans.tar.gz
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,6 @@ vendor/

/server
/data/
/tmp/
/tmp/
/coffee-beans/
coffee-beans.tar.gz
6 changes: 3 additions & 3 deletions handlers/ping.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,11 @@ package handlers

import "github.com/gin-gonic/gin"

// Ping handles a ping for healthcheck and discovery purposes
func Ping() func(*gin.Context) {
// HealthCheck handles a ping for healthcheck and discovery purposes
func HealthCheck() func(*gin.Context) {
return func(c *gin.Context) {
c.JSON(200, gin.H{
"message": "pong",
"message": "OK",
})
}
}
10 changes: 9 additions & 1 deletion main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package main
import (
"fmt"
"github.com/recrsn/coffee-beans/repositories"
"log"

"github.com/gin-gonic/gin"

Expand All @@ -11,14 +12,21 @@ import (
"github.com/recrsn/coffee-beans/utils"
)

var (
version = "dev"
commit = "HEAD"
)

func main() {
log.Printf("Coffee Beans %s (%s)\n", version, commit)

cfg, err := config.Load()
utils.Must(err)

router := gin.Default()
router.LoadHTMLGlob("templates/*")

router.GET("/ping", handlers.Ping())
router.GET("/health", handlers.HealthCheck())

manager := repositories.NewRepositoryManager(cfg.Server.BaseURL, cfg.Repositories)

Expand Down

0 comments on commit 44644fb

Please sign in to comment.