-
Notifications
You must be signed in to change notification settings - Fork 0
/
.gitlab-ci.yml
52 lines (47 loc) · 1.71 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
49
50
51
52
# This file is a template, and might need editing before it works on your project.
# Official docker image.
image: docker:latest
services:
- docker:dind
before_script:
- docker login -u "$CI_REGISTRY_USER" -p "$CI_REGISTRY_PASSWORD"
build-master:
stage: build
script:
- docker build --pull -t "sdvcrx/hugo-firebase" .
- docker push "sdvcrx/hugo-firebase"
only:
refs:
- master
changes:
- Dockerfile
build-tags:
stage: build
script:
- docker build --pull -t "sdvcrx/hugo-firebase:$CI_COMMIT_TAG" -t "sdvcrx/hugo-firebase" .
- docker push "sdvcrx/hugo-firebase:$CI_COMMIT_TAG"
- docker push "sdvcrx/hugo-firebase"
only:
- tags
check-update:
stage: build
script:
- apk update && apk add jq openssh-client git sed curl
- eval $(ssh-agent -s)
- echo "$GIT_SSH_PRIV_KEY"
- echo "$GIT_SSH_PRIV_KEY" | tr -d '\r' | ssh-add - > /dev/null
- git config --global user.email "[email protected]"
- git config --global user.name "sdvcrx-bot"
- mkdir -p ~/.ssh && chmod 700 ~/.ssh
- ssh-keyscan gitlab.com >> ~/.ssh/known_hosts
- git clone [email protected]:sdvcrx/docker-hugo-firebase.git
- cd docker-hugo-firebase
- DOCKER_TAG=$(grep 'ENV' Dockerfile | cut -d ' ' -f 3)
- LATEST_TAG=$(curl -m 10 --retry 5 --silent "https://api.github.com/repos/gohugoio/hugo/tags" | jq -r '.[0].name' | cut -d 'v' -f 2)
- if [ "$DOCKER_TAG" = "$LATEST_TAG" ]; then echo "latest tag is same => $DOCKER_TAG" && exit 0; fi
- sed -i "s|$DOCKER_TAG|$LATEST_TAG|g" Dockerfile
- git add Dockerfile && git commit -m "Update hugo to v$LATEST_TAG"
- git tag -a "$LATEST_TAG" -m "$LATEST_TAG"
- git push && git push --tags
only:
- schedules