Skip to content

Commit ff1bd43

Browse files
committed
Add actions
1 parent 36cbe98 commit ff1bd43

File tree

3 files changed

+107
-0
lines changed

3 files changed

+107
-0
lines changed

.github/workflows/docker.yml

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
name: Publish Docker image
2+
on:
3+
push:
4+
tags:
5+
- v*
6+
jobs:
7+
push_to_registry:
8+
name: Push Docker image to Docker Hub
9+
runs-on: ubuntu-latest
10+
steps:
11+
-
12+
name: Check out the repo
13+
uses: actions/checkout@v2
14+
-
15+
name: Prepare
16+
id: prep
17+
run: |
18+
DOCKER_IMAGE=chaspy/aws-ecr-image-scan-findings-prometheus-exporter
19+
VERSION=edge
20+
if [[ $GITHUB_REF == refs/tags/* ]]; then
21+
VERSION=${GITHUB_REF#refs/tags/}
22+
elif [[ $GITHUB_REF == refs/heads/* ]]; then
23+
VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
24+
elif [[ $GITHUB_REF == refs/pull/* ]]; then
25+
VERSION=pr-${{ github.event.number }}
26+
fi
27+
TAGS="${DOCKER_IMAGE}:${VERSION}"
28+
if [ "${{ github.event_name }}" = "push" ]; then
29+
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
30+
fi
31+
echo ::set-output name=version::${VERSION}
32+
echo ::set-output name=tags::${TAGS}
33+
echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
34+
-
35+
name: Set up Docker Buildx
36+
uses: docker/setup-buildx-action@v1
37+
-
38+
name: Login to DockerHub
39+
uses: docker/login-action@v1
40+
with:
41+
username: ${{ secrets.DOCKER_USERNAME }}
42+
password: ${{ secrets.DOCKER_PASSWORD }}
43+
-
44+
name: Build and push
45+
uses: docker/build-push-action@v2
46+
with:
47+
context: .
48+
file: ./Dockerfile
49+
push: ${{ github.event_name != 'pull_request' }}
50+
tags: ${{ steps.prep.outputs.tags }}
51+
cache-from: type=registry,ref=chaspy/aws-ecr-image-scan-findings-prometheus-exporter:latest
52+
cache-to: type=inline

.github/workflows/go.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: Go
2+
3+
on:
4+
push:
5+
pull_request:
6+
branches: [ main ]
7+
8+
jobs:
9+
10+
build:
11+
runs-on: ubuntu-latest
12+
steps:
13+
- uses: actions/checkout@v2
14+
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.15
19+
20+
- name: Build
21+
run: go build -v ./...
22+
23+
- name: Test
24+
run: go test -v ./...
25+
26+
- name: install lint
27+
run: curl -sfL https://install.goreleaser.com/github.com/golangci/golangci-lint.sh | sh -s -- -b $(go env GOPATH)/bin v1.35.2
28+
29+
- name: lint
30+
run: golangci-lint run

.github/workflows/release.yml

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
name: release
2+
3+
on:
4+
push:
5+
tags:
6+
- v*
7+
jobs:
8+
goreleaser:
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
with:
14+
fetch-depth: 0
15+
- name: Set up Go
16+
uses: actions/setup-go@v2
17+
with:
18+
go-version: 1.15
19+
- name: Run GoReleaser
20+
uses: goreleaser/goreleaser-action@v2
21+
with:
22+
version: latest
23+
args: release --rm-dist
24+
env:
25+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

0 commit comments

Comments
 (0)