如何克隆存储库,构建docker映像,从dockerfile获取git sha提交,在github中使用该sha commit释放标签并将文件从docker映像上传到它?
当然,如果有针对我的用例的其他解决方案,我将使用它。 :slight_smile: 谢谢
例如:
Dockerfile
FROM alpine:3.8
RUN apk update && apk add --no-cache git maven
RUN git clone https://github.com/efsavage/hello-world-war
RUN cd hello-world-war && mvn package
RUN cp target/my-app.jar /dest
RUN git log --format="%H" -n 1 > /dest/sha
.drone.yml
pipeline:
build:
image: docker
commands:
- docker build --force-rm --no-cache -t my-image .
- GIT_SHA=$(cat /dest/sha)
volumes:
- /var/run/docker.sock:/var/run/docker.sock
- /here:/dest
tag:
image: docker:git
secrets: [ github_token ]
commands:
- git config remote.origin.url https://{NEED_USERNAME}:{github_token }@github.com/{NEED_USERNAME}/{NEED_REPONAME}.git
- git tag vMY_APP_${GIT_SHA}
- git push origin vMY_APP_${GIT_SHA}
github_release:
image: plugins/github-release
secrets: [ github_token ]
files: /dest/my-app.jar
checksum:
- sha256
when:
event: tag
volumes:
- /here:/dest