-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (127 loc) · 5.03 KB
/
ci.yaml
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
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
# This file is managed via github.com/adorsys-containers/config
---
name: CI
on:
pull_request:
push:
branches:
- master
paths-ignore:
- 'README.md'
- '.sync.yml'
schedule:
- cron: '30 5 * * *'
jobs:
build:
strategy:
fail-fast: false
matrix:
env:
-
ALIASES: 'latest'
DIR: 'ubi'
DOCKER_IMAGE: 'adorsys/nginx'
SQUASH: 'true'
TAG: 'ubi'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
submodules: true
- uses: actions/setup-python@v2
if: matrix.env.SQUASH
with:
python-version: '3.x'
- uses: e1himself/[email protected]
with:
version: 'v0.3.14'
- name: docker info
run: docker info
- name: Install dependencies
run: |
npm install dockerfilelint
curl -sL https://github.com/gdraheim/docker-copyedit/archive/v1.2.2036.tar.gz | tar xzf - --wildcards --strip-components=1 */docker-copyedit.py
working-directory: ${{ matrix.env.DIR }}
# Implement some retry here since docker build depends against a lot of external dependencies
- name: docker build
env: ${{ matrix.env }}
run: |
for i in $(seq 1 5); do
docker build --pull -t "${DOCKER_IMAGE}:${TAG}" . && s=0 && break || s=$? && sleep 15;
done;
(exit $s)
working-directory: ${{ matrix.env.DIR }}
- name: Run tests
env: ${{ matrix.env }}
run: |
bash -xe "${{ matrix.env.DIR }}/tests/tests.sh"
npx dockerfilelint < "${{ matrix.env.DIR }}/Dockerfile"
find "${{ matrix.env.DIR }}/" -name '*.sh' -not -path "*/node_modules/*" -print0 | xargs -0 shellcheck
grep -lr --exclude-dir={.\*,node_modules} '#!/bin/sh' "${{ matrix.env.DIR }}/" | xargs --no-run-if-empty shellcheck
- name: Squash Docker Image
if: matrix.env.SQUASH
env: ${{ matrix.env }}
run: |
pip3 install wheel docker-squash
docker tag "${DOCKER_IMAGE}:${TAG}" "${DOCKER_IMAGE}:presquashed"
docker-squash -t "${DOCKER_IMAGE}:squashed" "${DOCKER_IMAGE}:${TAG}"
docker tag "${DOCKER_IMAGE}:squashed" "${DOCKER_IMAGE}:${TAG}"
- name: Report Image Size
env: ${{ matrix.env }}
run: |
docker images "${DOCKER_IMAGE}"
docker history "${DOCKER_IMAGE}:${TAG}"
docker run --rm -e CI=1 -v /var/run/docker.sock:/var/run/docker.sock wagoodman/dive:latest \
--highestUserWastedPercent disabled --lowestEfficiency disabled "${DOCKER_IMAGE}:${TAG}"
- name: Login to DockerHub
# https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
if: github.ref == 'refs/heads/master'
uses: docker/login-action@v1
with:
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
- name: Publish Image on DockerHub
# https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
if: github.ref == 'refs/heads/master'
env: ${{ matrix.env }}
run: |
for i in $(seq 1 5); do
docker push "${DOCKER_IMAGE}:${TAG}" && s=0 && break || s=$? && sleep 15;
done;
(exit $s)
- name: Publish Image aliases on DockerHub
# https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
if: github.ref == 'refs/heads/master' && matrix.env.ALIASES
env: ${{ matrix.env }}
run: |
for ALIAS in ${ALIASES}; do
echo "Pushing tag aliases ${ALIAS}"
docker tag "${DOCKER_IMAGE}:${TAG}" "${DOCKER_IMAGE}:${ALIAS}"
for i in $(seq 1 5); do
docker push "${DOCKER_IMAGE}:${ALIAS}" && s=0 && break || s=$? && sleep 15;
done;
(exit $s)
done
- name: Publish Image snapshosts on DockerHub
# https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
if: github.ref == 'refs/heads/master' && matrix.env.SNAPSHOT
env: ${{ matrix.env }}
run: |
if [ "$(date +%d)" -eq "1" ]; then
echo "Pushing snapshot tag $(date +%Y%m)"
docker tag "${DOCKER_IMAGE}:${TAG}" "${DOCKER_IMAGE}:$(date +%Y%m)"
for i in $(seq 1 5); do
docker push "${DOCKER_IMAGE}:$(date +%Y%m)" && s=0 && break || s=$? && sleep 15;
done;
(exit $s)
fi
- name: Slack notification if pipeline failed
# https://github.community/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
uses: 8398a7/[email protected]
with:
status: ${{ job.status }}
author_name: ${{ github.repository }}
fields: repo,commit,author,action
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}
if: github.ref == 'refs/heads/master' && failure()