Skip to content

Commit

Permalink
Change version extraction to GitHub Actions output.
Browse files Browse the repository at this point in the history
  • Loading branch information
apognu committed Feb 26, 2025
1 parent 123abb2 commit 2f8e083
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 3 deletions.
10 changes: 8 additions & 2 deletions .github/workflows/backend_deploy_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v4

with:
fetch-depth: 0
fetch-tags: true
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

Expand All @@ -41,13 +43,17 @@ jobs:
registry: europe-west1-docker.pkg.dev
username: oauth2accesstoken
password: ${{ steps.auth.outputs.access_token }}

- name: Extract version from tag
id: version
run: echo "MARBLE_VERSION=$(git describe --tags)" >> "$GITHUB_OUTPUT"

- name: Build and push
uses: docker/build-push-action@v5
with:
push: true
build-args: |
BUILDKIT_CONTEXT_KEEP_GIT_DIR=1
MARBLE_VERSION=${{ steps.version.outputs.MARBLE_VERSION }}
tags: ${{ env.IMAGE }}

- name: "Set up Cloud SDK"
Expand Down
4 changes: 3 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
FROM golang:1.23 as build

ARG MARBLE_VERSION=dev

WORKDIR /go/src/app
COPY . .

RUN go get

RUN CGO_ENABLED=0 go build -o /go/bin/app -ldflags="-X 'main.apiVersion=$(git describe --tags)'"
RUN CGO_ENABLED=0 go build -o /go/bin/app -ldflags="-X 'main.apiVersion=${MARBLE_VERSION}'"

FROM alpine:3.19

Expand Down

0 comments on commit 2f8e083

Please sign in to comment.