Skip to content

Commit

Permalink
initial commit
Browse files Browse the repository at this point in the history
Signed-off-by: He Weiwei <[email protected]>
  • Loading branch information
heww committed Aug 26, 2021
0 parents commit cac920e
Show file tree
Hide file tree
Showing 25 changed files with 3,286 additions and 0 deletions.
85 changes: 85 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,85 @@
name: Releases

on:
push:
branches:
- main

jobs:
create-release:
runs-on: ubuntu-latest
outputs:
release-id: ${{ steps.create_release.outputs.id }}
release-tag: ${{ steps.short-sha.outputs.sha }}
steps:
- uses: benjlevesque/[email protected]
id: short-sha

- name: Create Release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: ${{ steps.short-sha.outputs.sha }}
release_name: ${{ steps.short-sha.outputs.sha }}
body: |
Release ${{ steps.short-sha.outputs.sha }}
draft: false
prerelease: true

build-upload-assets:
needs: [create-release]
runs-on: ubuntu-latest
strategy:
matrix:
goos: [linux, windows, darwin]
goarch: [amd64]
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Run go generate
run: make go-generate

- name: Release ${{ matrix.goos }}-${{ matrix.goarch }}
uses: wangyoucao577/[email protected]
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
goos: ${{ matrix.goos }}
goarch: ${{ matrix.goarch }}
goversion: https://dl.google.com/go/go1.15.6.linux-amd64.tar.gz
pre_command: export CGO_ENABLED=0
build_flags: -a -tags netgo
binary_name: harbor-scanner-fake
release_tag: ${{ needs.create-release.outputs.release-tag }}

- name: Rollback Release
if: failure()
uses: author/action-rollback@stable
with:
release_id: ${{ needs.create-release.outputs.release-id }}
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

publish-release:
needs: [create-release, build-upload-assets]
runs-on: ubuntu-latest
steps:
- uses: meeDamian/[email protected]
with:
token: ${{ secrets.GITHUB_TOKEN }}
tag: ${{ needs.create-release.outputs.release-tag }}
prerelease: false
allow_override: true

delete-older-releases:
needs: [publish-release]
runs-on: ubuntu-latest
steps:
- uses: dev-drprasad/[email protected]
with:
keep_latest: 1
delete_tags: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
41 changes: 41 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
name: Tests

on: [push, pull_request]

jobs:
lint:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v2

- name: Setup Docker
uses: docker-practice/[email protected]
with:
docker_version: 20.04
docker_channel: stable

- name: Run lint
run: make lint

test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Set up Go
uses: actions/setup-go@v2
with:
go-version: 1.15.6

- name: Cache go mod
uses: actions/cache@v2
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Test
run: make test
92 changes: 92 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
# File created using '.gitignore Generator' for Visual Studio Code: https://bit.ly/vscode-gig

# Created by https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,go,macos
# Edit at https://www.toptal.com/developers/gitignore?templates=visualstudiocode,linux,go,macos

### Go ###
# Binaries for programs and plugins
*.exe
*.exe~
*.dll
*.so
*.dylib

# Test binary, built with `go test -c`
*.test

# Output of the go coverage tool, specifically when used with LiteIDE
*.out

# Dependency directories (remove the comment below to include it)
# vendor/

### Go Patch ###
/vendor/
/Godeps/

### Linux ###
*~

# temporary files which can be created if a process still has a handle open of a deleted file
.fuse_hidden*

# KDE directory preferences
.directory

# Linux trash folder which might appear on any partition or disk
.Trash-*

# .nfs files are created when an open file is removed but is still being accessed
.nfs*

### macOS ###
# General
.DS_Store
.AppleDouble
.LSOverride

# Icon must end with two \r
Icon


# Thumbnails
._*

# Files that might appear in the root of a volume
.DocumentRevisions-V100
.fseventsd
.Spotlight-V100
.TemporaryItems
.Trashes
.VolumeIcon.icns
.com.apple.timemachine.donotpresent

# Directories potentially created on remote AFP share
.AppleDB
.AppleDesktop
Network Trash Folder
Temporary Items
.apdisk

### VisualStudioCode ###
.vscode/*
!.vscode/settings.json
!.vscode/tasks.json
!.vscode/launch.json
!.vscode/extensions.json
*.code-workspace

### VisualStudioCode Patch ###
# Ignore all local history of files
.history
.ionide

# End of https://www.toptal.com/developers/gitignore/api/visualstudiocode,linux,go,macos

# Custom rules (everything added below won't be overriden by 'Generate .gitignore File' if you use 'Update' option)

out/bin/
junit-report.xml
coverage.xml
profile.cov
config.yaml
25 changes: 25 additions & 0 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
FROM golang:1.16-buster AS build

WORKDIR /app

COPY go.mod ./
COPY go.sum ./
RUN go mod download

COPY . ./

RUN go build -o /harbor-scanner-fake


# hadolint ignore=DL3006
FROM gcr.io/distroless/base-debian10

WORKDIR /

COPY --from=build /harbor-scanner-fake /harbor-scanner-fake

EXPOSE 8080

USER nonroot:nonroot

ENTRYPOINT ["/harbor-scanner-fake"]
Loading

0 comments on commit cac920e

Please sign in to comment.