This repository has been archived by the owner on Jan 1, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 5
/
.travis.yml
89 lines (83 loc) · 3.04 KB
/
.travis.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
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
---
stages:
- yaml-lint
- build
- push
env:
global:
- YAMLLINT_VERSION="1.15.0"
- PRETTIER_VERSION="1.16.4"
- WORKSPACE="/ci-actions/workspace"
before_script:
- docker pull smoloney/ci-actions-yamllint:"${YAMLLINT_VERSION}"
- docker pull smoloney/ci-actions-prettier:"${PRETTIER_VERSION}"
jobs:
include:
- stage: yaml-lint
language: bash
script:
- |
docker run --rm -v "${PWD}:${WORKSPACE}" \
smoloney/ci-actions-yamllint:"${YAMLLINT_VERSION}" \
--exclude='./deployment/helm/templates' \
--file-glob='*.y*ml' \
--exec-args='yamllint --strict --config-file=.yamllint.yml' && \
docker run --rm -v "${PWD}:${WORKSPACE}" \
smoloney/ci-actions-prettier:"${PRETTIER_VERSION}" \
--exclude='./deployment/helm/templates' \
--file-glob='*.y*ml' \
--exec-args='prettier --check --parser yaml --config ./.prettierrc.yml'
- &docker_prepare
stage: build
env:
- DOCKERHUB_USERNAME=smoloney
- DOCKERHUB_REPO=saleor
- DOCKERHUB_URL="${DOCKERHUB_USERNAME}/${DOCKERHUB_REPO}"
- SALEOR_BRANCH=master
language: bash
if: |
branch != master
before_script:
- |
git clone https://github.com/mirumee/saleor.git --branch=${SALEOR_BRANCH} &&
cd saleor &&
cp ../Dockerfile ./
script:
- |
docker build --tag ${DOCKERHUB_URL}:local-only . &&
docker run --rm ${DOCKERHUB_URL}:local-only /bin/bash -c 'echo "build ok"'
- <<: *docker_prepare
stage: push
if: |
branch = master
before_script:
- |
git remote set-branches origin master && git fetch &&
export git_diff=$(git diff-tree -r --name-only HEAD remotes/origin/master) &&
git clone https://github.com/mirumee/saleor.git --branch=${SALEOR_BRANCH} &&
cd saleor &&
cp ../Dockerfile ./ &&
export LATEST_SALEOR_TAG=$(git rev-parse $(git rev-parse HEAD)) &&
export LATEST_SALEOR_TAG=${LATEST_SALEOR_TAG:0:6} &&
export RECENTLY_BUILT_IMAGES=$(
curl --silent https://hub.docker.com/v2/repositories/${DOCKERHUB_URL}/tags/ | \
jq '.results | .[] | .name'
) &&
echo ${git_diff} &&
if [[ ${RECENTLY_BUILT_IMAGES} != "" && \
${RECENTLY_BUILT_IMAGES} == *"${LATEST_SALEOR_TAG}"* ]]; then
if [[ "${git_diff}" != *"Dockerfile"* ]]; then
export SKIP=true;
fi
fi
script:
- |
if [[ -z ${SKIP} ]]; then
echo "${DOCKERHUB_PASSWORD}" | \
docker login -u "${DOCKERHUB_USERNAME}" --password-stdin
docker build --tag ${DOCKERHUB_URL}:latest . &&
docker tag ${DOCKERHUB_URL}:latest \
${DOCKERHUB_URL}:${SALEOR_BRANCH}-${LATEST_SALEOR_TAG} &&
docker push ${DOCKERHUB_URL}:latest && docker push \
${DOCKERHUB_URL}:${SALEOR_BRANCH}-${LATEST_SALEOR_TAG}
fi