Skip to content

Commit

Permalink
Docker build dont ignore ci env vars (woodpecker-ci#2238)
Browse files Browse the repository at this point in the history
  • Loading branch information
6543 committed Aug 18, 2023
1 parent 7d73263 commit e58c70e
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 4 deletions.
15 changes: 15 additions & 0 deletions .woodpecker/docker.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ variables:
- &platforms_server 'linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le,linux/riscv64'
- &platforms_preview 'linux/amd64'
- &platforms_alpine 'linux/arm/v6,linux/arm/v7,linux/arm64/v8,linux/amd64,linux/ppc64le'
- &build_args 'CI_COMMIT_SHA=${CI_COMMIT_SHA},CI_COMMIT_BRANCH=${CI_COMMIT_BRANCH},CI_COMMIT_TAG=${CI_COMMIT_TAG}'

# vars used on push / tag events only
- publish_logins: &publish_logins
Expand Down Expand Up @@ -199,6 +200,7 @@ steps:
dockerfile: docker/Dockerfile.agent.multiarch
platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST}
build_args: *build_args
when:
event: pull_request

Expand All @@ -211,6 +213,7 @@ steps:
platforms: *platforms_release
tag: [next, "next-${CI_COMMIT_SHA:0:10}"]
logins: *publish_logins
build_args: *build_args
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
Expand All @@ -224,6 +227,7 @@ steps:
platforms: *platforms_alpine
tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"]
logins: *publish_logins
build_args: *build_args
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
Expand All @@ -237,6 +241,7 @@ steps:
platforms: *platforms_release
tag: ${CI_COMMIT_BRANCH##release/}
logins: *publish_logins
build_args: *build_args
when:
branch: release/*
event: push
Expand All @@ -250,6 +255,7 @@ steps:
platforms: *platforms_alpine
tag: ${CI_COMMIT_BRANCH##release/}
logins: *publish_logins
build_args: *build_args
when:
branch: release/*
event: push
Expand All @@ -264,6 +270,7 @@ steps:
# remove 'latest' on older version branches to avoid accidental downgrade
tag: [latest, "${CI_COMMIT_TAG}"]
logins: *publish_logins
build_args: *build_args
when:
event: tag

Expand All @@ -277,6 +284,7 @@ steps:
# remove 'latest-alpine' on older version branches to avoid accidental downgrade
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
logins: *publish_logins
build_args: *build_args
when:
event: tag

Expand All @@ -293,6 +301,7 @@ steps:
dockerfile: docker/Dockerfile.cli.multiarch
platforms: *platforms_preview
tag: pull_${CI_COMMIT_PULL_REQUEST}
build_args: *build_args
when:
event: pull_request

Expand All @@ -305,6 +314,7 @@ steps:
platforms: *platforms_release
tag: [next, "next-${CI_COMMIT_SHA:0:10}"]
logins: *publish_logins
build_args: *build_args
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
Expand All @@ -318,6 +328,7 @@ steps:
platforms: *platforms_alpine
tag: [next-alpine, "next-${CI_COMMIT_SHA:0:10}-alpine"]
logins: *publish_logins
build_args: *build_args
when:
branch: ${CI_REPO_DEFAULT_BRANCH}
event: push
Expand All @@ -331,6 +342,7 @@ steps:
platforms: *platforms_release
tag: ${CI_COMMIT_BRANCH##release/}
logins: *publish_logins
build_args: *build_args
when:
branch: release/*
event: push
Expand All @@ -344,6 +356,7 @@ steps:
platforms: *platforms_alpine
tag: ${CI_COMMIT_BRANCH##release/}
logins: *publish_logins
build_args: *build_args
when:
branch: release/*
event: push
Expand All @@ -358,6 +371,7 @@ steps:
# remove 'latest' on older version branches to avoid accidental downgrade
tag: [latest, "${CI_COMMIT_TAG}"]
logins: *publish_logins
build_args: *build_args
when:
event: tag

Expand All @@ -371,5 +385,6 @@ steps:
# remove 'latest-alpine' on older version branches to avoid accidental downgrade
tag: [latest-alpine, "${CI_COMMIT_TAG}-alpine"]
logins: *publish_logins
build_args: *build_args
when:
event: tag
2 changes: 1 addition & 1 deletion docker/Dockerfile.agent.alpine.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build

WORKDIR /src
COPY . .
ARG TARGETOS TARGETARCH
ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build-agent
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.agent.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build

WORKDIR /src
COPY . .
ARG TARGETOS TARGETARCH
ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build-agent
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.cli.alpine.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build

WORKDIR /src
COPY . .
ARG TARGETOS TARGETARCH
ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build-cli
Expand Down
2 changes: 1 addition & 1 deletion docker/Dockerfile.cli.multiarch
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ FROM --platform=$BUILDPLATFORM golang:1.20 AS build

WORKDIR /src
COPY . .
ARG TARGETOS TARGETARCH
ARG TARGETOS TARGETARCH CI_COMMIT_SHA CI_COMMIT_TAG CI_COMMIT_BRANCH
RUN --mount=type=cache,target=/root/.cache/go-build \
--mount=type=cache,target=/go/pkg \
make build-cli
Expand Down

0 comments on commit e58c70e

Please sign in to comment.