mirror of
https://github.com/krau/SaveAny-Bot.git
synced 2026-06-09 01:20:37 +08:00
ci: fix version inject
This commit is contained in:
10
.github/workflows/build-docker.yml
vendored
10
.github/workflows/build-docker.yml
vendored
@@ -44,6 +44,12 @@ jobs:
|
|||||||
username: ${{ github.actor }}
|
username: ${{ github.actor }}
|
||||||
password: ${{ secrets.GITHUB_TOKEN }}
|
password: ${{ secrets.GITHUB_TOKEN }}
|
||||||
|
|
||||||
|
- name: Extract Dockerfile args
|
||||||
|
id: args
|
||||||
|
run: |
|
||||||
|
echo "git_commit=$(git rev-parse --short HEAD)" >> "$GITHUB_OUTPUT"
|
||||||
|
echo "build_time=$(git show -s --format=%cI)" >> "$GITHUB_OUTPUT"
|
||||||
|
|
||||||
- name: Build and push Docker image
|
- name: Build and push Docker image
|
||||||
id: build-and-push
|
id: build-and-push
|
||||||
uses: docker/build-push-action@v6
|
uses: docker/build-push-action@v6
|
||||||
@@ -59,5 +65,5 @@ jobs:
|
|||||||
cache-to: type=gha,mode=max
|
cache-to: type=gha,mode=max
|
||||||
build-args: |
|
build-args: |
|
||||||
VERSION=${{ steps.meta.outputs.version }}
|
VERSION=${{ steps.meta.outputs.version }}
|
||||||
GitCommit=${{ github.sha }}
|
GitCommit=${{ steps.args.outputs.git_commit }}
|
||||||
BuildTime=${{ fromJson(toJSON(github.event.repository.pushed_at)) }}
|
BuildTime=${{ steps.args.outputs.build_time }}
|
||||||
|
|||||||
16
Dockerfile
16
Dockerfile
@@ -13,12 +13,14 @@ RUN --mount=type=cache,target=/go/pkg/mod \
|
|||||||
COPY . .
|
COPY . .
|
||||||
RUN --mount=type=cache,target=/root/.cache/go-build \
|
RUN --mount=type=cache,target=/root/.cache/go-build \
|
||||||
--mount=type=cache,target=/go/pkg \
|
--mount=type=cache,target=/go/pkg \
|
||||||
CGO_ENABLED=0 \
|
CGO_ENABLED=0 \
|
||||||
go build -trimpath \
|
go build -trimpath \
|
||||||
-ldflags "-s -w \
|
-ldflags=" \
|
||||||
-X github.com/krau/SaveAny-Bot/common.Version=${VERSION} \
|
-s -w \
|
||||||
-X github.com/krau/SaveAny-Bot/common.GitCommit=${GitCommit} \
|
-X 'github.com/krau/SaveAny-Bot/common.Version=${VERSION}' \
|
||||||
-X github.com/krau/SaveAny-Bot/common.BuildTime=${BuildTime}" \
|
-X 'github.com/krau/SaveAny-Bot/common.GitCommit=${GitCommit}' \
|
||||||
|
-X 'github.com/krau/SaveAny-Bot/common.BuildTime=${BuildTime}' \
|
||||||
|
" \
|
||||||
-o saveany-bot .
|
-o saveany-bot .
|
||||||
|
|
||||||
FROM alpine:latest
|
FROM alpine:latest
|
||||||
@@ -33,4 +35,4 @@ COPY entrypoint.sh .
|
|||||||
RUN chmod +x /app/saveany-bot && \
|
RUN chmod +x /app/saveany-bot && \
|
||||||
chmod +x /app/entrypoint.sh
|
chmod +x /app/entrypoint.sh
|
||||||
|
|
||||||
ENTRYPOINT ["/app/entrypoint.sh"]
|
ENTRYPOINT ["/app/entrypoint.sh"]
|
||||||
|
|||||||
Reference in New Issue
Block a user