-
Notifications
You must be signed in to change notification settings - Fork 2
/
.gitlab-ci.yml
48 lines (43 loc) · 1.31 KB
/
.gitlab-ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
stages:
- build-docker
- publish-git
# Build Docker & deploy to Docker Hub
build_docker:dockerhub:
stage: build-docker
tags:
- buildx
only:
- master
cache: {}
variables:
DOCKERFILE: Dockerfile
IMAGE_TAG_DOCKER_HUB: samibourouis/balena-cli
before_script:
- docker info
- docker buildx version
- docker buildx use gitlab-runner-builder
- docker buildx inspect --bootstrap
- docker login -u ${DOCKER_HUB_USERNAME} -p ${DOCKER_HUB_PASSWORD}
script:
- docker buildx build --no-cache --platform linux/amd64 -t ${IMAGE_TAG_DOCKER_HUB} -f ${DOCKERFILE} ${DOCKER_BUILD_ARGS} . --push
- BALENA_CLI_VERSION=`docker run -i --rm ${IMAGE_TAG_DOCKER_HUB} balena version`
- echo $BALENA_CLI_VERSION
- docker tag ${IMAGE_TAG_DOCKER_HUB} ${IMAGE_TAG_DOCKER_HUB}:$BALENA_CLI_VERSION
- docker push ${IMAGE_TAG_DOCKER_HUB}:$BALENA_CLI_VERSION
# Publish to Github
github_mirror:
stage: publish-git
image:
name: alpine/git
entrypoint: [ "/bin/sh", "-c" ]
only:
- master
variables:
GIT_STRATEGY: clone
GIT_CHECKOUT: "false"
script: |
cd /tmp
git clone --mirror ${CI_REPOSITORY_URL} project
cd project
git remote add github https://${GITHUB_USER}:${GITHUB_TOKEN}@github.com/samibourouis/balena-cli-docker.git
git push --mirror github