Skip to content

Commit

Permalink
github: build and push docker container
Browse files Browse the repository at this point in the history
Signed-off-by: Date Huang <[email protected]>
  • Loading branch information
tjjh89017 committed Sep 19, 2024
1 parent 5e868ea commit 452474b
Showing 1 changed file with 31 additions and 3 deletions.
34 changes: 31 additions & 3 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ on:

env:
GO_VERSION: "1.22"
APP: ${{ github.repository }}

jobs:
codegen:
Expand All @@ -24,6 +25,7 @@ jobs:
run: |
git diff --compact-summary --exit-code || \
(echo; echo "Unexpected difference in directories after code generation. Run 'wire .' command and commit."; exit 1)
lint:
name: Lint
runs-on: ubuntu-latest
Expand Down Expand Up @@ -70,12 +72,38 @@ jobs:
with:
go-version: ${{ env.GO_VERSION }}
- name: Build
run: go build -v -o stunmesh-${{ matrix.os }}-${{ matrix.arch }} .
run: go build -v -o ${{ env.APP}}-${{ matrix.os }}-${{ matrix.arch }} .
env:
CGO_ENABLED: 0
GOARCH: ${{ matrix.arch }}
GOOS: ${{ matrix.os }}
- uses: actions/upload-artifact@v4
with:
name: stunmesh-${{ matrix.os }}-${{ matrix.arch }}
path: stunmesh-${{ matrix.os }}-${{ matrix.arch }}
name: ${{ env.APP }}-${{ matrix.os }}-${{ matrix.arch }}
path: ${{ env.APP }}-${{ matrix.os }}-${{ matrix.arch }}

docker:
if: github.event_name != 'pull_request'
name: Build Docker container
runs-on: ubuntu-latest
needs:
- lint
- test
steps:
- uses: actions/checkout@v4
- uses: docker/setup-qemu-action@v3
- uses: docker/setup-buildx-action@v3
- uses: docker/login-action@v3
with:
username: ${{ github.repository_owner }}
password: ${{ secrets.DOCKER_TOKEN }}
- uses: docker/metadata-action@v5
id: meta
with:
images: ${{ github.repository_owner }}/${{ env.APP }}
- uses: docker/build-push-action@v6
with:
platforms: linux/amd64,linux/arm64,linux/arm
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}

0 comments on commit 452474b

Please sign in to comment.