-
Notifications
You must be signed in to change notification settings - Fork 0
127 lines (121 loc) · 5.02 KB
/
docker.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
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
name: Docker
on:
pull_request:
push:
tags:
- v*
paths:
- .github/workflows/docker.yml
- cmd
- go.mod
- go.sum
- internal
- pkg
- infra/docker
jobs:
# cancel any existing runs of this workflow on this branch
cancel-currently-running:
if: github.event_name == 'pull_request'
runs-on: ubuntu-latest
steps:
- uses: rokroskar/workflow-run-cleanup-action@v0.3.3
env:
GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}"
build:
runs-on: ubuntu-latest
env:
# enable BuildKit
# https://www.docker.com/blog/faster-builds-in-compose-thanks-to-buildkit-support/
COMPOSE_DOCKER_CLI_BUILD: 1
DOCKER_BUILDKIT: 1
steps:
- id: get-version
uses: battila7/get-version-action@v2
# logging in is necessary to use cache-from in builds and pushes
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout (without LFS)
uses: actions/checkout@v2
- name: Fetch videos from cache
id: restore-videos
uses: actions/cache@v2.1.7
with:
path: assets/video
key: ${{ runner.os }}-video-${{ hashFiles('assets/video/manifest.txt') }}
restore-keys: |
${{ runner.os }}-video-
# use git-lfs to download big video file(s)
# (but only if the cache hit missed)
- name: Checkout (with LFS)
uses: actions/checkout@v2
if: steps.restore-videos.outputs.cache-hit != 'true'
continue-on-error: true
with:
lfs: true
- name: Build tripbot
run: docker-compose --project-directory . -f infra/docker/docker-compose.yml -f infra/docker/docker-compose.testing.yml -f infra/docker/docker-compose.github.yml build tripbot
- name: Build obs
run: docker-compose --project-directory . -f infra/docker/docker-compose.yml -f infra/docker/docker-compose.testing.yml -f infra/docker/docker-compose.github.yml build obs
- name: Start the docker-compose stack
env:
# pass these into tripbot
CHANNEL_NAME: ${{ secrets.CHANNEL_NAME }}
BOT_USERNAME: ${{ secrets.BOT_USERNAME }}
TWITCH_AUTH_TOKEN: ${{ secrets.TWITCH_AUTH_TOKEN }}
TWITCH_CLIENT_ID: ${{ secrets.TWITCH_CLIENT_ID }}
TWITCH_CLIENT_SECRET: ${{ secrets.TWITCH_CLIENT_SECRET }}
run: docker-compose --project-directory . --env-file infra/docker/env.docker -f infra/docker/docker-compose.yml -f infra/docker/docker-compose.testing.yml -f infra/docker/docker-compose.github.yml up -d
- run: sleep 10
- name: Check logs (migrate)
run: docker logs tripbot_migrate_1
- name: Check logs (obs)
run: docker logs tripbot_obs_1
- name: Check logs (tripbot) 🤖
run: docker logs tripbot_tripbot_1
- name: Check running containers
run: docker ps -a
- name: Stop containers
run: docker-compose --project-directory . -f infra/docker/docker-compose.yml -f infra/docker/docker-compose.testing.yml -f infra/docker/docker-compose.github.yml down
if: always() # run this even if previous steps fail
continue-on-error: true
#TODO: consider taking a screenshot:
# docker exec -e DISPLAY=:0.0 -w /tmp tripbot_obs_1 scrot -z -t 20 -e 'cat $m && rm $f $m' > screenshot.png
# - name: Run a healthcheck against tripbot
# run: curl -v https://tripbot:8080/health
# - name: Run test suite
# run: docker exec tripbot go test ./...
- name: Push Docker images
if: startsWith(github.ref, 'refs/tags/v')
env:
VERSION_TAG: ${{ steps.get-version.outputs.version }}
MAJOR: ${{ steps.get-version.outputs.major }}
MINOR: ${{ steps.get-version.outputs.minor }}
run: |
# push tripbot
docker push adanalife/tripbot:latest
docker tag adanalife/tripbot adanalife/tripbot:$VERSION_TAG
docker push adanalife/tripbot:$VERSION_TAG
docker tag adanalife/tripbot adanalife/tripbot:v$MAJOR
docker push adanalife/tripbot:v$MAJOR
docker tag adanalife/tripbot adanalife/tripbot:v$MAJOR.$MINOR
docker push adanalife/tripbot:v$MAJOR.$MINOR
# push obs
docker push adanalife/obs:latest
docker tag adanalife/obs adanalife/obs:$VERSION_TAG
docker push adanalife/obs:$VERSION_TAG
docker tag adanalife/obs adanalife/obs:v$MAJOR
docker push adanalife/obs:v$MAJOR
docker tag adanalife/obs adanalife/obs:v$MAJOR.$MINOR
docker push adanalife/obs:v$MAJOR.$MINOR
#TODO: move this to a deploy.yml and announce deploys
- name: Post Discord notification
if: startsWith(github.ref, 'refs/tags/v')
env:
DISCORD_WEBHOOK: ${{ secrets.DISCORD_WEBHOOK }}
VERSION_TAG: ${{ steps.get-version.outputs.version }}
uses: Ilshidur/action-discord@0.3.2
with:
args: 'New Docker image created for [{{ EVENT_PAYLOAD.repository.full_name }}]({{ EVENT_PAYLOAD.repository.html_url }}): [{{ VERSION_TAG }}]({{ EVENT_PAYLOAD.compare }})'