diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c259bc1..d30ab1d 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,11 +1,9 @@ -name: Test +name: CI on: push: branches: - "**" - tags-ignore: - - "*" jobs: test: @@ -15,10 +13,26 @@ jobs: go-version: [ '1.20', '1.21', '1.22' ] steps: - - uses: actions/checkout@v4 + - uses: actions/checkout@v4 - - uses: actions/setup-go@v5 - with: - go-version: ${{ matrix.go-version }} + - uses: actions/setup-go@v5 + with: + go-version: ${{ matrix.go-version }} - - run: go test -v ./... + - run: go test -v ./... + + publish: + runs-on: ubuntu-latest + needs: test + if: startsWith(github.ref, 'refs/tags/') + steps: + - name: Fetch all tags + run: git fetch --force --tags + + - name: Run GoReleaser + uses: goreleaser/goreleaser-action@v5 + with: + version: latest + args: release --clean + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} diff --git a/.goreleaser.yml b/.goreleaser.yml new file mode 100644 index 0000000..87aca15 --- /dev/null +++ b/.goreleaser.yml @@ -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 diff --git a/cmd/syncpeeps.go b/cmd/cli/main.go similarity index 54% rename from cmd/syncpeeps.go rename to cmd/cli/main.go index 3689708..40001c9 100644 --- a/cmd/syncpeeps.go +++ b/cmd/cli/main.go @@ -3,7 +3,7 @@ package main import ( "os" - personnel_sync "github.com/silinternational/personnel-sync/v6" + sync "github.com/silinternational/personnel-sync/v6" ) func main() { @@ -11,7 +11,7 @@ func main() { 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) diff --git a/cmd/lambda/main.go b/cmd/lambda/main.go new file mode 100644 index 0000000..9fdf6f7 --- /dev/null +++ b/cmd/lambda/main.go @@ -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) +}