Bump actions/setup-go from 2.1.5 to 5.2.0 #950
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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/[email protected] | |
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/[email protected] | |
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/[email protected] | |
with: | |
args: 'New Docker image created for [{{ EVENT_PAYLOAD.repository.full_name }}]({{ EVENT_PAYLOAD.repository.html_url }}): [{{ VERSION_TAG }}]({{ EVENT_PAYLOAD.compare }})' |