Skip to content

Commit 9430c47

Browse files
author
andersh
committed
fix: add github workflows
1 parent 228c4eb commit 9430c47

4 files changed

Lines changed: 87 additions & 0 deletions

File tree

.github/workflows/image.yml

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
name: Docker Image
2+
3+
on:
4+
push:
5+
tags: [ 'v*.*.*' ]
6+
7+
jobs:
8+
docker:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Docker Buildx
13+
uses: docker/setup-buildx-action@v3
14+
- name: Login to GitHub Container Registry
15+
uses: docker/login-action@v3
16+
with:
17+
registry: ghcr.io
18+
username: ${{ github.actor }}
19+
password: ${{ secrets.GITHUB_TOKEN }}
20+
- name: Build and push Docker image
21+
uses: docker/build-push-action@v5
22+
with:
23+
context: .
24+
push: true
25+
tags: |
26+
ghcr.io/${{ github.repository }}:${{ github.ref_name }}
27+
ghcr.io/${{ github.repository }}:latest
28+
build-args: |
29+
VERSION=${{ github.ref_name }}

.github/workflows/lint.yml

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
name: Lint
2+
3+
on:
4+
push:
5+
branches: [ main ]
6+
pull_request:
7+
branches: [ main ]
8+
9+
jobs:
10+
lint:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v4
14+
- name: Set up Go
15+
uses: actions/setup-go@v5
16+
with:
17+
go-version: '1.22'
18+
- name: Run go fmt
19+
run: go fmt ./...
20+
- name: Run go vet
21+
run: go vet ./...

.github/workflows/release.yml

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release
2+
3+
on:
4+
push:
5+
tags: [ 'v*.*.*' ]
6+
7+
jobs:
8+
release:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
- name: Set up Go
13+
uses: actions/setup-go@v5
14+
with:
15+
go-version: '1.22'
16+
- name: Build
17+
run: go build -ldflags "-X main.version=${GITHUB_REF_NAME}" -v ./...
18+
- name: Create GitHub Release
19+
uses: softprops/action-gh-release@v2
20+
with:
21+
files: |
22+
./web_proxy_cache

Dockerfile

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
# Build stage
2+
FROM golang:1.22-alpine AS builder
3+
WORKDIR /app
4+
COPY go.mod go.sum ./
5+
RUN go mod download
6+
COPY . .
7+
ARG VERSION=dev
8+
RUN CGO_ENABLED=0 GOOS=linux go build -ldflags "-X main.version=${VERSION}" -o web_proxy_cache .
9+
10+
# Final image
11+
FROM alpine:3.19
12+
WORKDIR /app
13+
COPY --from=builder /app/web_proxy_cache .
14+
EXPOSE 8080
15+
ENTRYPOINT ["./web_proxy_cache"]

0 commit comments

Comments
 (0)