Skip to content

CI

CI #1871

Workflow file for this run

# 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:
-
DIR: 'images/2.16'
DOCKER_IMAGE: 'adorsys/ci-helm'
SQUASH: 'true'
TAG: '2.16'
-
ALIASES: '2'
DIR: 'images/2.17'
DOCKER_IMAGE: 'adorsys/ci-helm'
SQUASH: 'true'
TAG: '2.17'
-
DIR: 'images/3.5'
DOCKER_IMAGE: 'adorsys/ci-helm'
SQUASH: 'true'
TAG: '3.5'
-
DIR: 'images/3.6'
DOCKER_IMAGE: 'adorsys/ci-helm'
SQUASH: 'true'
TAG: '3.6'
-
ALIASES: '3 latest'
DIR: 'images/3.7'
DOCKER_IMAGE: 'adorsys/ci-helm'
SQUASH: 'true'
TAG: '3.7'
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/goss-installation-action@v1.0.3
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://gh.neting.ccmunity/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://gh.neting.ccmunity/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://gh.neting.ccmunity/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://gh.neting.ccmunity/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://gh.neting.ccmunity/t5/GitHub-Actions/GitHub-Actions-branch-conditional/m-p/29794
uses: 8398a7/action-slack@v3.8.0
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()