Skip to content

feat: own default workflow #2

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion .dockerignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
example
.travis.yml
.git
.github
traefik-forward-auth
1 change: 0 additions & 1 deletion .github/FUNDING.yml
Original file line number Diff line number Diff line change
@@ -1,2 +1 @@
github: thomseddon

36 changes: 0 additions & 36 deletions .github/workflows/ci.yml

This file was deleted.

71 changes: 0 additions & 71 deletions .github/workflows/codeql-analysis.yml

This file was deleted.

63 changes: 63 additions & 0 deletions .github/workflows/default.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
name: Default
on:
push:
branches:
- '*'
pull_request:
branches:
- main

jobs:
build:
name: Build
runs-on: ubuntu-latest

steps:
- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: ^1.18
id: go

- name: Cache Go modules
uses: actions/cache@v2
with:
path: |
~/go/pkg
~/.cache/go-build
key: ${{ runner.os }}-${{ matrix.go-version }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-${{ matrix.go-version }}-go-

- name: Checkout
uses: actions/checkout@v3

- name: remove golangci from precommit-configuration
run: |
sed -i 's/.*id: golangci-lint//' .pre-commit-config.yaml
sed -i '/^\s*$/d' .pre-commit-config.yaml

- uses: pre-commit/[email protected]
continue-on-error: true

- name: Build
run: make build

- name: Lint
uses: golangci/golangci-lint-action@v3
with:
version: latest
skip-pkg-cache: true
skip-build-cache: true

- uses: go-semantic-release/action@v1
id: semrel
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
changelog-file: CHANGELOG.md

- uses: rhysd/changelog-from-release/action@v2
if: steps.semrel.outputs.version != ''
with:
file: CHANGELOG.md
github_token: ${{ secrets.GITHUB_TOKEN }}
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
traefik-forward-auth
18 changes: 18 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
---
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
hooks:
- id: check-yaml
args: [--allow-multiple-documents]
- id: end-of-file-fixer
- id: trailing-whitespace
- repo: https://github.com/dnephin/pre-commit-golang
rev: v0.5.1
hooks:
- id: go-fmt
- id: no-go-testing
- id: go-unit-tests
- id: go-build
- id: go-mod-tidy
- id: golangci-lint
33 changes: 25 additions & 8 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,18 +1,35 @@
FROM golang:1.13-alpine as builder
FROM golang:1.22-alpine as builder

# Setup
RUN mkdir -p /go/src/github.com/thomseddon/traefik-forward-auth
WORKDIR /go/src/github.com/thomseddon/traefik-forward-auth
# build
ARG TARGETOS
ARG TARGETARCH
ARG TARGETVARIANT

RUN case "${TARGETVARIANT}" in \
"armhf") export GOARM='6' ;; \
"armv7") export GOARM='6' ;; \
"v6") export GOARM='6' ;; \
"v7") export GOARM='7' ;; \
esac;

# Add libraries
RUN apk add --no-cache git
RUN apk add --no-cache git make ca-certificates

# Setup
WORKDIR /build

# download modules
COPY go.mod .
COPY go.sum .
RUN go mod download


# Copy & build
ADD . /go/src/github.com/thomseddon/traefik-forward-auth/
RUN CGO_ENABLED=0 GOOS=linux GOARCH=amd64 GO111MODULE=on go build -a -installsuffix nocgo -o /traefik-forward-auth github.com/thomseddon/traefik-forward-auth/cmd
COPY . .
RUN CGO_ENABLED=0 GOOS=${TARGETOS} GOARCH=${TARGETARCH} make build

# Copy into scratch container
FROM scratch
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/
COPY --from=builder /traefik-forward-auth ./
COPY --from=builder /build/traefik-forward-auth ./
ENTRYPOINT ["./traefik-forward-auth"]
18 changes: 0 additions & 18 deletions Dockerfile.arm

This file was deleted.

18 changes: 0 additions & 18 deletions Dockerfile.arm64

This file was deleted.

43 changes: 41 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,8 +1,47 @@
TAG_NAME := $(shell test -d .git && git describe --abbrev=0 --tags || echo "")
SHA := $(shell test -d .git && git rev-parse --short HEAD)
COMMIT := $(SHA)
# hide commit for releases
ifeq ($(RELEASE),1)
COMMIT :=
endif
ARTEFACT := traefik-forward-auth
VERSION := $(if $(TAG_NAME),$(TAG_NAME),$(SHA))
BUILD_DATE := $(shell date -u '+%Y-%m-%d_%H:%M:%S')
BUILD_TAGS:= -a -installsuffix nocgo
#BUILD_ARGS := -trimpath

IMAGE := mabunixda/$(ARTEFACT)
PLATFORM := linux/arm64,linux/amd64,linux/arm/v7

default: clean format build

clean:
rm -f $(ARTEFACT)

format:
gofmt -w -s internal/*.go internal/provider/*.go cmd/*.go
gofmt -w -l $$(find . -name '*.go')

test:
go test -v ./...

.PHONY: format test
porcelain::
gofmt -w -l $$(find . -name '*.go')
go mod tidy
test -z "$$(git status --porcelain)" || (git status; git diff; false)

build::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
CGO_ENABLED=0 go build -o $(ARTEFACT) $(BUILD_TAGS) $(BUILD_ARGS) ./cmd/

docker::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker buildx build --platform $(PLATFORM) --tag $(IMAGE):testing .

publish-testing::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker build --platform $(PLATFORM) --tag $(IMAGE):testing --push .

publish-latest::
@echo Version: $(VERSION) $(SHA) $(BUILD_DATE)
docker build --platform $(PLATFORM) --tag $(IMAGE):latest --tag $(IMAGE):$(VERSION) --push .
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
port: 80
selector:
app: whoami

Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
---
#
# RBAC
# Source: traefik/templates/rbac.yaml
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
port: 80
selector:
app: whoami

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
port: 80
selector:
app: whoami

Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,3 @@ spec:
port: 80
selector:
app: whoami

1 change: 0 additions & 1 deletion examples/traefik-v2/swarm/docker-compose-oidc.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,3 @@ services:
- "traefik.http.middlewares.traefik-forward-auth.forwardauth.address=http://traefik-forward-auth:4181"
- "traefik.http.middlewares.traefik-forward-auth.forwardauth.authResponseHeaders=X-Forwarded-User"
- "traefik.http.services.traefik-forward-auth.loadbalancer.server.port=4181"

Loading