Skip to content

Commit

Permalink
use GoReleaser to build and publish a Lambda binary
Browse files Browse the repository at this point in the history
  • Loading branch information
briskt committed Apr 9, 2024
1 parent c0630a5 commit 3c362b2
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 4 deletions.
11 changes: 9 additions & 2 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ on:
push:
branches:
- "**"
tags-ignore:
- "*"

jobs:
test:
Expand All @@ -22,3 +20,12 @@ jobs:
go-version: ${{ matrix.go-version }}

- run: go test -v ./...

- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v5
if: startsWith(github.ref, 'refs/tags/')
with:
version: latest
args: release --clean
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
17 changes: 17 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# This is the configuration for goreleaser
# Check the documentation at http://goreleaser.com for details
before:
hooks:
- go mod tidy
builds:
- main: ./cmd/lambda
env:
- CGO_ENABLED=0
goos:
- linux
goarch:
- amd64
flags:
- -tags=lambda.norpc
gomod:
proxy: true
4 changes: 2 additions & 2 deletions cmd/syncpeeps.go → cmd/cli/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@ package main
import (
"os"

personnel_sync "github.com/silinternational/personnel-sync/v6"
sync "github.com/silinternational/personnel-sync/v6"
)

func main() {
configFile := ""
if len(os.Args) > 1 {
configFile = os.Args[1]
}
if err := personnel_sync.RunSync(configFile); err != nil {
if err := sync.RunSync(configFile); err != nil {
os.Exit(1)
}
os.Exit(0)
Expand Down
19 changes: 19 additions & 0 deletions cmd/lambda/main.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package main

import (
"github.com/aws/aws-lambda-go/lambda"

sync "github.com/silinternational/personnel-sync/v6"
)

type LambdaConfig struct {
ConfigPath string
}

func main() {
lambda.Start(handler)
}

func handler(lambdaConfig LambdaConfig) error {
return sync.RunSync(lambdaConfig.ConfigPath)
}

0 comments on commit 3c362b2

Please sign in to comment.