golang private module
1.0.0
Ir a módulos con repositorio GIT privado
go env -w GOPRIVATE=github.com/appleboy
git config --global url. " https:// $USERNAME : $ACCESS_TOKEN @github.com " .insteadOf " https://github.com "
prueba el repositorio privado:
go get github.com/appleboy/golang-private
steps :
- name : build
image : golang:1.13
environment :
USERNAME :
from_secret : username
ACCESS_TOKEN :
from_secret : access_token
commands :
- go env -w GOPRIVATE=github.com/$USERNAME
- git config --global url."https://$USERNAME:[email protected]".insteadOf "https://github.com"
- go mod tidy
- go build -o main .
Vea lo siguiente:
# Start from the latest golang base image
FROM golang:1.14 as Builder
RUN GOCACHE=OFF
RUN go env -w GOPRIVATE=github.com/appleboy
# Set the Current Working Directory inside the container
WORKDIR /app
# Copy everything from the current directory to the Working Directory inside the container
COPY . .
ARG ACCESS_TOKEN
ENV ACCESS_TOKEN=$ACCESS_TOKEN
RUN git config --global url. "https://appleboy:${ACCESS_TOKEN}@github.com" .insteadOf "https://github.com"
# Build the Go app
RUN go build -o main .
FROM scratch
COPY --from=Builder /app/main /
CMD [ "/main" ]
cree una imagen usando Drone y obtenga el token de acceso a la ventana acoplable en la sección de seguridad de la configuración.
- name : build-image
image : plugins/docker
environment :
ACCESS_TOKEN :
from_secret : access_token
settings :
username :
from_secret : username
password :
from_secret : password
repo : appleboy/golang-module-private
build_args_from_env :
- ACCESS_TOKEN