Skip to content

Commit

Permalink
chore: add pull-request CI automation
Browse files Browse the repository at this point in the history
Allow PRs to generate images pushed to GHCR.
  • Loading branch information
smlx committed Nov 20, 2021
1 parent 4fcf622 commit 4919938
Show file tree
Hide file tree
Showing 5 changed files with 92 additions and 1 deletion.
39 changes: 39 additions & 0 deletions .github/workflows/build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
name: Build
on: pull_request
jobs:
build:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "^1.17"
- name: Set up environment
run: echo "GOVERSION=$(go version)" >> $GITHUB_ENV
- name: Run GoReleaser
uses: goreleaser/goreleaser-action@v2
with:
version: latest
args: build --snapshot --rm-dist
- name: Login to GHCR
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Docker metadata
id: service_api_meta
uses: docker/metadata-action@v3
with:
images: uselagoon/lagoon-ssh-portal/service-api
- name: Build and push service-api container image
id: docker_build
uses: docker/build-push-action@v2
with:
push: true
tags: ghcr.io/${{ steps.service_api_meta.outputs.tags }}
labels: ${{ steps.service_api_meta.outputs.labels }}
file: deploy/service-api/Dockerfile
context: dist/lagoon-ssh-portal_linux_amd64
22 changes: 22 additions & 0 deletions .github/workflows/lint.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
name: Lint
on: pull_request
jobs:
golangci-lint:
name: lint
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: golangci-lint
uses: golangci/[email protected]
with:
version: latest
commitlint:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
with:
fetch-depth: 0
- name: Lint commit messages
uses: wagoid/[email protected]
14 changes: 14 additions & 0 deletions .github/workflows/test.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
name: Test
on: pull_request
jobs:
go-test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Install Go
uses: actions/setup-go@v2
with:
go-version: "^1.17"
- name: Run Tests
run: go test -v ./...
9 changes: 9 additions & 0 deletions .goreleaser.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
builds:
- dir: cmd/service-api
binary: service-api
ldflags:
- >
-s -w -X main.date={{.Date}} -X "main.goVersion={{.Env.GOVERSION}}"
-X main.shortCommit={{.ShortCommit}} -X main.version={{.Version}}
env:
- CGO_ENABLED=0
9 changes: 8 additions & 1 deletion internal/serviceapi/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,14 @@ func sshportal(log *zap.Logger, c *nats.EncodedConn, l LagoonDBService,
// calculate permission
ok := permission.UserCanSSHToEnvironment(env, realmRoles, userGroups,
groupProjectIDs)
c.Publish(reply, ok)
if err = c.Publish(reply, ok); err != nil {
log.Error("couldn't publish reply",
zap.Any("query", query),
zap.Bool("reply value", ok),
zap.String("user UUID", user.UUID.String()),
zap.Error(err))
return
}
}
}

Expand Down

0 comments on commit 4919938

Please sign in to comment.