Skip to content
This repository was archived by the owner on Jul 19, 2023. It is now read-only.

Commit a3c51d5

Browse files
authored
build: add initial docker push workflow (#111)
1 parent 544b070 commit a3c51d5

2 files changed

Lines changed: 47 additions & 3 deletions

File tree

.github/workflows/release.yml

Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,3 +42,46 @@ jobs:
4242
env:
4343
GITHUB_TOKEN: ${{ secrets.CI_GITHUB_TOKEN }}
4444
run: bash ./scripts/brew_push_formula.sh ${{ github.event.inputs.release_version }}
45+
46+
docker:
47+
runs-on: ubuntu-latest
48+
steps:
49+
-
50+
name: Checkout
51+
uses: actions/checkout@v2
52+
-
53+
name: Set up QEMU
54+
uses: docker/setup-qemu-action@v1
55+
-
56+
name: Set up Docker Buildx
57+
uses: docker/setup-buildx-action@v1
58+
-
59+
name: Build and export to Docker
60+
uses: docker/build-push-action@v2
61+
with:
62+
context: .
63+
load: true
64+
tags: |
65+
allero/allero-cli:${{ github.event.inputs.release_version }}
66+
allero/allero-cli:latest
67+
-
68+
name: Test
69+
run: |
70+
docker run --rm allero/allero-cli:${{ github.event.inputs.release_version }}
71+
-
72+
name: Login to DockerHub
73+
uses: docker/login-action@v1
74+
if: github.event_name != 'pull_request'
75+
with:
76+
username: ${{ secrets.DOCKERHUB_USERNAME }}
77+
password: ${{ secrets.DOCKERHUB_TOKEN }}
78+
-
79+
name: Build and push
80+
uses: docker/build-push-action@v2
81+
with:
82+
context: .
83+
push: true
84+
build-args: cli-version=${{ github.event.inputs.release_version }}
85+
tags: |
86+
allero/allero-cli:${{ github.event.inputs.release_version }}
87+
allero/allero-cli:latest

Dockerfile

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
11
FROM golang:1.19-alpine AS builder
22
RUN apk --no-cache add curl gcc g++
33

4+
ARG cli-version
5+
46
WORKDIR /go/src/app
57
COPY . .
68

7-
RUN curl -H "Authorization: token $GITHUB_TOKEN" --silent "https://api.github.com/repos/allero-io/allero-wip/releases/latest" | grep '"tag_name":' | sed -E 's/.*"([^"]+)".*/\1/' > cli-version
89
RUN go get -d -v ./...
9-
RUN go build -tags main -ldflags="-X github.com/allero-io/allero/cmd.CliVersion=$(cat cli-version)" -v
10+
RUN go build -tags main -ldflags="-X github.com/allero-io/allero/cmd.CliVersion=${cli-version}" -v
1011

1112
FROM alpine:3.14
1213
COPY --from=builder /go/src/app/allero /
13-
ENTRYPOINT ["/allero"]
14+
ENTRYPOINT ["/allero"]

0 commit comments

Comments
 (0)