Description
Issue
When using an Alpine image in Github Actions runner, actions/checkout will put git into a bad state, causing go build
to run into a vcs issue. go build
is running into issue because its detecting git info through the .git
folder but is not able to get the version info it needed and will exit with code 1.
Logs
Github actions image used: https://github.com/kiloexabyte/runner-image/blob/main/Dockerfile
Workflow logs: https://github.com/kiloexabyte/vcs-issue-demo/actions/runs/15571879590/job/43849297094
Workflow file: https://github.com/kiloexabyte/vcs-issue-demo/blob/main/.github/workflows/push-main.yml
workflow:
name: Push to main
on:
push:
branches: [main]
jobs:
build:
runs-on: ubuntu-latest
container:
image: kiloexabyte/runner-image
steps:
- uses: actions/checkout@v4
- run: |
go build
image definition of kiloexabyte/runner-image
:
FROM alpine:3.19
# Environment variables for Go
ENV GOLANG_VERSION=1.24.3 \
GOROOT=/usr/local/go \
GOPATH=/go \
PATH=/usr/local/go/bin:/go/bin:$PATH
# Install system packages, Go, and Docker CLI
RUN apk add --no-cache \
bash \
curl \
git \
docker-cli \
ca-certificates \
nodejs \
npm \
tar \
zip \
aws-cli \
&& curl -LO https://golang.org/dl/go${GOLANG_VERSION}.linux-amd64.tar.gz \
&& tar -C /usr/local -xzf go${GOLANG_VERSION}.linux-amd64.tar.gz \
&& rm go${GOLANG_VERSION}.linux-amd64.tar.gz \
&& mkdir -p /go/src /go/bin /go/pkg \
&& wget https://releases.hashicorp.com/terraform/1.8.4/terraform_1.8.4_linux_amd64.zip \
&& unzip terraform_1.8.4_linux_amd64.zip -d /usr/local/bin \
&& rm terraform_1.8.4_linux_amd64.zip
# Install the 'op' tool
RUN go install lesiw.io/op@latest
# Install the 'golangci-lint' tool
RUN go install github.com/golangci/golangci-lint/v2/cmd/golangci-lint@v2.1.6
# Default command
CMD ["go", "version"]
note: I know there are work around like passing the flag -buildvcs=false
to go build
but I was curious what cause this issue