Skip to content

Commit 7390fde

Browse files
Merge pull request #2 from step-security/release
onboarding codeowners-validator action
2 parents 867271c + d10d445 commit 7390fde

90 files changed

Lines changed: 5173 additions & 1 deletion

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.dockerignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
.git
2+
.github
3+
docs
4+
hack
5+
tests
6+
bin
7+
coverage.txt
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
name: Release GitHub Actions
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
tag:
7+
description: "Tag for the release"
8+
required: true
9+
10+
permissions:
11+
contents: read
12+
13+
jobs:
14+
release:
15+
permissions:
16+
actions: read
17+
id-token: write
18+
contents: write
19+
20+
uses: step-security/reusable-workflows/.github/workflows/actions_release.yaml@v1
21+
with:
22+
tag: "${{ github.event.inputs.tag }}"
Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
name: Auto Cherry-Pick from Upstream
2+
3+
on:
4+
workflow_run:
5+
workflows: ["Release GitHub Actions"]
6+
types:
7+
- completed
8+
workflow_dispatch:
9+
inputs:
10+
base_branch:
11+
description: "Base branch to create the PR against"
12+
required: true
13+
default: "main"
14+
mode:
15+
description: "Run mode: cherry-pick or verify"
16+
required: false
17+
default: "cherry-pick"
18+
19+
pull_request:
20+
types: [opened, synchronize, labeled]
21+
22+
permissions:
23+
contents: write
24+
pull-requests: write
25+
packages: read
26+
issues: write
27+
28+
jobs:
29+
cherry-pick:
30+
if: github.event_name == 'workflow_dispatch' || contains(fromJson(toJson(github.event.pull_request.labels)).*.name, 'review-required')
31+
uses: step-security/reusable-workflows/.github/workflows/auto_cherry_pick.yaml@v1
32+
with:
33+
original-owner: "mszostok"
34+
repo-name: "codeowners-validator"
35+
base_branch: ${{ inputs.base_branch }}
36+
mode: ${{ github.event_name == 'pull_request' && 'verify' || inputs.mode }}

.github/workflows/docker.yml

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
name: Publish docker image
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
release_tag:
7+
description: 'Tag to release'
8+
required: true
9+
type: string
10+
11+
permissions:
12+
contents: read
13+
packages: write
14+
15+
jobs:
16+
build:
17+
runs-on: ubuntu-latest
18+
if: startsWith(github.event.inputs.release_tag, 'v')
19+
steps:
20+
- name: Harden the runner (Audit all outbound calls)
21+
uses: step-security/harden-runner@0v2
22+
with:
23+
egress-policy: audit
24+
25+
- name: Checkout
26+
uses: actions/checkout@v6
27+
- name: Validate tag format
28+
run: |
29+
TAG=${{ github.event.inputs.release_tag }}
30+
if ! echo "$TAG" | grep -Eq '^v[0-9]+\.[0-9]+\.[0-9]+$'; then
31+
echo "❌ Invalid tag format: $TAG"
32+
exit 1
33+
fi
34+
echo "✅ Valid semver tag: $TAG"
35+
- name: Log in to GitHub Container Registry
36+
uses: step-security/docker-login-action@v4
37+
with:
38+
registry: ghcr.io
39+
username: ${{ github.actor }}
40+
password: ${{ secrets.GITHUB_TOKEN }}
41+
42+
- name: Set up QEMU for ARM builds
43+
uses: step-security/setup-qemu-action@v4
44+
45+
- name: Set up Docker Buildx
46+
uses: step-security/setup-buildx-action@v4
47+
48+
- name: Build and push Docker image
49+
uses: step-security/docker-build-push-action@v7
50+
with:
51+
context: .
52+
push: true
53+
platforms: linux/amd64,linux/arm64
54+
tags: |
55+
ghcr.io/${{ github.repository }}:${{ github.event.inputs.release_tag }}
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
name: Pull request
2+
3+
on:
4+
pull_request:
5+
branches: [ main ]
6+
7+
env:
8+
GO111MODULE: on
9+
INSTALL_DEPS: true
10+
11+
defaults:
12+
run:
13+
shell: bash
14+
15+
concurrency:
16+
group: ${{ github.workflow }}-${{ github.ref_name }}-${{ github.event.pull_request.number || 'branch' }} # scope to for the current workflow
17+
cancel-in-progress: ${{ github.event_name == 'pull_request' }} # cancel only PR related jobs
18+
19+
jobs:
20+
unit-test:
21+
strategy:
22+
fail-fast: false
23+
matrix:
24+
os: ${{ github.actor == 'dependabot[bot]' && fromJSON('["ubuntu-latest"]') || fromJSON('["ubuntu-latest", "macos-latest"]') }}
25+
runs-on: ${{ matrix.os }}
26+
steps:
27+
- uses: actions/checkout@v6
28+
- name: Set up Go
29+
uses: actions/setup-go@v6
30+
with:
31+
go-version-file: 'go.mod'
32+
cache: true
33+
- name: "Build and unit-test"
34+
run: make test-unit
35+
- name: "Hammer unit-test"
36+
run: make test-hammer
37+
code-quality-test:
38+
runs-on: ubuntu-latest
39+
steps:
40+
- uses: actions/checkout@v6
41+
- name: Set up Go
42+
uses: actions/setup-go@v6
43+
with:
44+
go-version-file: 'go.mod'
45+
cache: true
46+
- name: "Code Quality Analysis"
47+
run: make test-lint

.gitignore

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
scripts/
2+
.idea
3+
codeowners-validator
4+
dist/
5+
tmp/
6+
bin/
7+
coverage.txt

.golangci.yml

Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
issues:
2+
exclude:
3+
# Check this issue for more info: https://github.com/kyoh86/scopelint/issues/4
4+
- Using the variable on range scope `tc` in function literal
5+
6+
run:
7+
tests: true
8+
linters:
9+
disable-all: true
10+
enable:
11+
- gocritic
12+
- errcheck
13+
- gosimple
14+
- govet
15+
- ineffassign
16+
- staticcheck
17+
- typecheck
18+
- unused
19+
- revive
20+
- gofmt
21+
- misspell
22+
- gochecknoinits
23+
- unparam
24+
- exportloopref
25+
- gosec
26+
- goimports
27+
- whitespace
28+
- bodyclose
29+
- gocyclo
30+
31+
fast: false
32+
33+
34+
linters-settings:
35+
gocritic:
36+
enabled-tags:
37+
- diagnostic
38+
- style
39+
- performance
40+
- experimental
41+
- opinionated

Dockerfile

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
FROM golang:1.21-alpine AS builder
2+
3+
# hadolint ignore=DL3018
4+
RUN apk --no-cache add ca-certificates git
5+
6+
WORKDIR /app
7+
COPY go.mod go.sum ./
8+
RUN go mod download
9+
COPY . .
10+
RUN CGO_ENABLED=0 GOOS=linux go build -o /codeowners-validator .
11+
12+
FROM scratch
13+
14+
LABEL org.opencontainers.image.source=https://github.com/step-security/codeowners-validator
15+
16+
COPY --from=builder /codeowners-validator /codeowners-validator
17+
COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
18+
COPY --from=builder /usr/bin/git /usr/bin/git
19+
COPY --from=builder /usr/bin/xargs /usr/bin/xargs
20+
COPY --from=builder /lib /lib
21+
COPY --from=builder /usr/lib /usr/lib
22+
23+
ENTRYPOINT ["/codeowners-validator"]

0 commit comments

Comments
 (0)