Skip to content

Commit

Permalink
hello world notifications
Browse files Browse the repository at this point in the history
  • Loading branch information
ckaserer committed Dec 17, 2019
1 parent 815ba42 commit 35377a4
Show file tree
Hide file tree
Showing 5 changed files with 116 additions and 115 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
.DS_Store
.travis/config.yml
.travis/travis.sh
60 changes: 43 additions & 17 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,47 @@
---
version: "~> 1.0"
os: linux
language: shell
services: docker

notifications:
email:
on_success: never
on_failure: never
slack:
if: branch = master
rooms:
secure: YZYwVjd1oqoV3NYIGony8DuPn9DUbY8MepFgHO4I/G/qMBha1UHfWi3iZE9eC5ryr2G7kJJOZkLWQJRjKlOLtPALLhsYlgYhCuTe5rfZ7z9zcFyNw7EIDvj12DbE0OMo3axZlPH+zqBfwkYMMzFb9jcf4dYLyX7uz+2jkeSN4FmeiS0pOTGjHEzJr4YGqSpbMCk8ilrJgzkE8H54897sioP5C5311ivRH4gImeWT+Ml7KPsLZqsmGYu2VutlWurekZm464Ovwy3XL5CFUWu5U7Z2phQwR16H+JplIfIs9Pj9j4cn+VU2Q+3Xc1rM0Td+wf9fy2eOftNfqPQNY73qwBN2rsndwJ/0hB8/yUuM4JeVoSSQjQwjlA0rhKOAjibd7llFFGoXAr49pUZtyUv7Wp7HDOi6ggkr4N/4OkoXH9FuWgo/LcIMb9/xlvu9zP+phc1ZwkT7FTe8WvgKaotTMul0kEudRQn79OoWOJ3YU1jIRRs8+GgvSzflYuED8vSe9q5+BxrWha5WbDEywmQ9B+m72ooff2do1gvujlWU2ftnle4R8khUrAx8x8HDxfSXICXqFtcn8mwyvytwtgb6icJbZZEc1q0OIpX2J1x9SqlygmuErm+cbanvBTxrkX/D2jZYdEIsXRntr0nVs1Q1+uImOgpyVLaQDNzE8ry3sRo=
template:
- "%{commit_subject}"
- build <%{build_url}|#%{build_number}> (<%{compare_url}|%{commit}>) @%{branch}
- by %{author} %{result} in %{duration}
on_success: change
on_failure: always
env:
- REPO='docker-template' TAG='latest' MICROSCANNER_OPTIONS='--continue-on-failure'

jobs:
- REPO='hello-world' TAG='latest' ORGANIZATION='gepardec'
global:
- secure: T3nA4PTr+XXZPIlbZZn//EImCzHYmtSui6WJOZ11qjubISUpABukslGUf1SlkEJrgtwhjlaPtcYS1/bb+I8+iRebYlL1xB0rqcsoOdHopOuxdfIbnc/Y6c9hlSBZQe1gL/L6cmfPcSWROHetCY+pRfy6BXHfjH14KLAHCBocvInobhENvbY4ylDdbVPLF0j/VrX1rETElMHm9JmqWNyb3UJpcjBPi1dReDhUG7PItQkejGk5fS94i6qwkWmvWciJh02aswKcGD9dWfg1ujoh6k7leJOs/fYNthBeElJDiReTodvdyb4sP7jmv5UN4mnD65xCdDkhYkrzzgyuYcfNVCjFoIYK6pOpSAaPm45L71B5v9XpNTEbSsM2nH7nXbycd8QongZcAJ/mX/SNAbyzcoIh14ndfe+twmP29nP0Xt1bejUcGqqczcf2nSUakrnM4TcgPnJ98fNNgVVxxobrXgZGCFkLdsVRhHlOAhpITHrCCOa0zGUrv3xmG4PiAq6FEcVchkXQ2QWEYg7A4ygU49CpHTBx1mxbBcaAMcOnTjI3NT1Anra7EmhOdUy5kL/AyKe2v3u4lymJjhEf2duClCmp/SDuSUeldyEiD9oWMT/dzrZ6gud8skT1FCuzL/nWS88Ce//PmBR9ykFpVl8D7OjKsLUjaLJhHNX+o3qf9oc=
- secure: cfcz5lHkbCKA2YUCJF+J2oUQaefmZjy9LvSaYUXxea9XPqgp1bV1XXeUfKaPXuEpYSCoMtWM2Bnszx/A3HHC9izRUy+wz0g8OWJ/+o4y7FsXf7E+HdNuj7LLM0m+BGImOHO9O9IgR5l6PgBk+Gn/PeA7X198PRG10OxgNi8jPRfNVkkhk80HfuDtQ2m3Nq8z+yojB0mBfJ318GF2hqENCHxXLzMi3mZXLekI0L7OWQWXGplvkXEdcjmpKAIjG9n1ZwgzSoWTdzb2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AYmGTSx8WwvpYMAkv8iTcAj4=
before_install:
- |
curl -fsSL https://github.com/ckaserer/bash-script-collection/archive/master.zip > bash-script-collection.zip
unzip -j bash-script-collection.zip -d bash-script-collection
rm bash-script-collection.zip
script:
- docker build -t ${ORGANIZATION}/${REPO}:${TAG} --no-cache .
# security check
- >
if [ "${TRAVIS_PULL_REQUEST}" = "false" ]; then
.travis/security-scan.sh ${ORGANIZATION}/${REPO}:${TAG}
else
echo "security scan does not run for pull request. For further information see: https://docs.travis-ci.com/user/pull-requests/#pull-requests-and-security-restrictions"
- |
set -ex
docker build -t ${ORGANIZATION}/${REPO}:${TAG} --no-cache .
docker run --rm -it ${ORGANIZATION}/${REPO}:${TAG}
set +ex
deploy:
provider: script
script: bash ./bash-script-collection/docker-push-image.sh
skip_cleanup: true
on:
branch: master
after_failure:
- |
if [ "${TRAVIS_BRANCH}" == "master" ]; then
./bash-script-collection/googlechat-send-notification.sh
fi
# push image
- >
if [ "$TRAVIS_BRANCH" == "master" ]; then
echo "${DOCKER_PASS}" | docker login -u "${DOCKER_USER}" --password-stdin
docker push ${ORGANIZATION}/${REPO}
fi
93 changes: 0 additions & 93 deletions .travis/security-scan.sh

This file was deleted.

3 changes: 2 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
FROM centos:8
FROM centos:7
CMD ["echo", "Hello World"]
72 changes: 68 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
[![Build Status](https://travis-ci.com/gepardec/docker-template.svg?branch=master)](https://travis-ci.com/gepardec/docker-template)
[![Docker Automated build](https://img.shields.io/docker/automated/gepardec/docker-template.svg?maxAge=2592000)](https://hub.docker.com/r/gepardec/docker-template/)
![Docker Pulls](https://img.shields.io/docker/pulls/gepardec/docker-template)
![Docker Pulls](https://img.shields.io/docker/pulls/gepardec/hello-world)
![GitHub](https://img.shields.io/github/license/gepardec/docker-template)
![Maintenance](https://img.shields.io/maintenance/yes/2019)
![Maintenance](https://img.shields.io/maintenance/yes/2020)
<p align="right">
<img alt="gepardec" width=100px src="https://github.com/Gepardec/docker-template/raw/master/.images/gepardec.png">
</p>
Expand All @@ -11,4 +10,69 @@

# docker-template

CentOS 8 Docker container with ...
CentOS 7 container image with ...

---

# Getting started

1) Create a new repository and use this repo as **template**
2) Update the badge links in `README.md`
3) add docker credentials to be able to push your image to dockerhub
4) add build notifications (slack and/or google hangout)
5) remove the "Getting started" section in `README.md`
6) write your own Dockerfile and enjoy CI and notifications

## Add docker credentials

1) use ckaserer/docker-travis-cli to encrypt your docker credentials

git clone https://github.com/ckaserer/docker-travis-cli.git
source docker-travis-cli/bashrc
add-docker-credentials "dockerUsername"

```
docker run --rm -i -e TZ=Europe/Vienna -v $(pwd):/root -w=/root ckaserer/travis-cli add-docker-credentials "dockerUsername"
```

## How to set up slack notifications

1) login to https://team-gepardec.slack.com/
2) go to https://team-gepardec.slack.com/apps/A0F81FP4N-travis-ci
3) Click add to slack
4) Choose channel #travis
5) Click "Add Travis Integration"
6) Customize the name and icon for integration e.g. your repo name "docker-template" + icon of the key technology in this case "docker"
7) on top you will find setup instructions. You can't just copy and paste them!
8) use ckaserer/docker-travis-cli to encrypt your slack token

git clone https://github.com/ckaserer/docker-travis-cli.git
source docker-travis-cli/bashrc
add-slack-token "workspace:myToken"

```
docker run --rm -i -e TZ=Europe/Vienna -v $(pwd):/root -w=/root ckaserer/travis-cli add-slack-token "workspace:myToken"
```

## How to set up google chat notifications

1) open google chat
2) open the room that you would like to add notifications too (e.g. Builds)
3) click on the Dropdown next to the name of the room
4) click on "Configure webhooks"
5) Set a name (preferably the repo slug) and an avatar url
6) Click "Save"
6) Copy the webhook url
7) use ckaserer/docker-travis-cli to encrypt your slack token

```
git clone https://github.com/ckaserer/docker-travis-cli.git
source docker-travis-cli/bashrc
add-googlechat-webhook "myWebhookUrl"
```

or run following command directly

```
docker run --rm -i -e TZ=Europe/Vienna -v $(pwd):/root -w=/root ckaserer/travis-cli add-googlechat-webhook "myWebhookUrl"
```

0 comments on commit 35377a4

Please sign in to comment.