golang private module
1.0.0
Buka Modul dengan Repositori GIT Pribadi
go env -w GOPRIVATE=github.com/appleboy
git config --global url. " https:// $USERNAME : $ACCESS_TOKEN @github.com " .insteadOf " https://github.com "
coba repo pribadi:
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 .
Lihat yang berikut ini:
# 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" ]
buat gambar menggunakan Drone dan dapatkan token akses buruh pelabuhan di bagian pengaturan keamanan.
- 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