From 5bdbedf3e3a4f0130b257c6dad317f9c922e06be Mon Sep 17 00:00:00 2001 From: Zespre Schmidt Date: Mon, 18 Nov 2024 00:32:20 +0800 Subject: [PATCH] ci: pass in app version and commit sha Signed-off-by: Zespre Schmidt --- .github/workflows/main.yml | 7 ++++++- .github/workflows/pull-request.yaml | 7 ++++++- .github/workflows/tag.yml | 7 ++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a89b224..b8bddcb 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -34,11 +34,16 @@ jobs: images: ${{ matrix.image }} - name: Docker build and push uses: docker/build-push-action@v6 + env: + VERSION: ${{ github.ref_name }}-head + GIT_COMMIT: ${{ github.sha }} with: provenance: false context: . + build-args: | + LINKFLAGS=-X main.AppVersion=${{ env.VERSION }} -X main.GitCommit=${{ env.GIT_COMMIT }} platforms: linux/amd64,linux/arm64 file: ${{ matrix.dockerfile }} push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/pull-request.yaml b/.github/workflows/pull-request.yaml index d45dcf0..e1a3395 100644 --- a/.github/workflows/pull-request.yaml +++ b/.github/workflows/pull-request.yaml @@ -40,11 +40,16 @@ jobs: run: make build - name: Docker build uses: docker/build-push-action@v6 + env: + VERSION: ${{ github.event.pull_request.head.ref }}-head + GIT_COMMIT: ${{ github.sha }} with: provenance: false context: . + build-args: | + LINKFLAGS=-X main.AppVersion=${{ env.VERSION }} -X main.GitCommit=${{ env.GIT_COMMIT }} platforms: linux/amd64,linux/arm64 file: ${{ matrix.dockerfile }} push: false - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/tag.yml b/.github/workflows/tag.yml index 6e9d337..abe29d3 100644 --- a/.github/workflows/tag.yml +++ b/.github/workflows/tag.yml @@ -34,11 +34,16 @@ jobs: images: ${{ matrix.image }} - name: Docker build and push uses: docker/build-push-action@v6 + env: + VERSION: ${{ github.ref_name }} + GIT_COMMIT: ${{ github.sha }} with: provenance: false context: . + build-args: | + LINKFLAGS=-X main.AppVersion=${{ env.VERSION }} -X main.GitCommit=${{ env.GIT_COMMIT }} platforms: linux/amd64,linux/arm64 file: ${{ matrix.dockerfile }} push: true - tags: ${{ steps.meta.outputs.tags }} + tags: ${{ env.VERSION }} labels: ${{ steps.meta.outputs.labels }}