Skip to content

Commit

Permalink
Implement ci workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
avakarev committed Sep 13, 2022
1 parent 1e96ff8 commit 9ec464d
Show file tree
Hide file tree
Showing 2 changed files with 65 additions and 0 deletions.
45 changes: 45 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: ci
on: [push]

jobs:
hadolint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: hadolint/[email protected]
with:
ignore: DL3018
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-go@v3
with:
go-version: 1.18
- name: Lint & Test
run: make setup-ci ci
docker:
needs: [hadolint, test]
runs-on: ubuntu-latest
env:
IMGTAG: ghcr.io/avakarev/lidl-connect-exporter
steps:
- uses: actions/checkout@v3
- id: git
run: |
echo "::set-output name=sha::$(git rev-parse --short HEAD)"
echo "::set-output name=ref::${GITHUB_REF##*/}"
- uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- uses: docker/build-push-action@v3
with:
tags: |
${{ env.IMGTAG }}:${{ steps.git.outputs.sha }}
${{ env.IMGTAG }}:${{ steps.git.outputs.ref }}
build-args: |
GITHUB_SHA=${{ steps.git.outputs.sha }}
GITHUB_REF=${{ steps.git.outputs.ref }}
push: true
20 changes: 20 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
ARG GO_VERSION=1.18

FROM golang:${GO_VERSION}-alpine AS builder
ARG GITHUB_SHA
ARG GITHUB_REF
RUN apk add --no-cache ca-certificates tzdata make
WORKDIR /src
COPY go.mod go.sum Makefile ./
RUN go mod download
COPY cmd ./cmd
COPY internal ./internal
RUN make build

FROM scratch
USER 1000
WORKDIR /app
COPY --from=builder /src/bin/server /app/server
COPY --from=builder /usr/share/zoneinfo /usr/share/zoneinfo
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
CMD ["/app/server"]

0 comments on commit 9ec464d

Please sign in to comment.