-
Notifications
You must be signed in to change notification settings - Fork 2
108 lines (101 loc) · 3.73 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
# This is a basic workflow to help you get started with Actions
name: Docker
# Controls when the action will run. Triggers the workflow on push or pull request
# events but only for the master branch
on:
workflow_dispatch: # on button click
pull_request: # PRs
push:
branches:
- master
paths:
- "**.py"
- "requirements*.txt"
- ".github/workflows/docker.yml"
- "Dockerfile"
- "**.po"
# A workflow run is made up of one or more jobs that can run sequentially or in parallel
jobs:
build:
name: Build docker image
runs-on: ubuntu-latest
steps:
- name: Cancel Previous Runs
uses: styfle/[email protected]
with:
access_token: ${{ github.token }}
- uses: actions/checkout@master
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to GitHub Container Registry
if: ${{ github.event_name == 'push' }}
uses: docker/login-action@v1
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Set up QEMU
id: qemu
uses: docker/setup-qemu-action@v1
with:
image: tonistiigi/binfmt:latest
platforms: all
- name: Query Tag
id: tag
uses: jimschubert/query-tag-action@v2
- name: Publish to Registry
if: always()
uses: docker/build-push-action@v2
with:
tags: ghcr.io/octo-tg-bot/octotgbot:latest
build-args: |
CI=true
DESCRIBE=${{steps.tag.outputs.tag}}
push: ${{ github.event_name == 'push' }}
target: release
platforms: linux/amd64
cache-from: type=gha
cache-to: type=gha,mode=max
deployment:
name: Deploy docker image
needs: build
runs-on: ubuntu-latest
if: ${{ github.event_name == 'push' }}
steps:
- name: Install jq and curl
run: sudo apt update && sudo apt install jq curl
- name: Start deployment
uses: bobheadxi/deployments@master
id: deployment
with:
step: start
token: ${{ secrets.GITHUB_TOKEN }}
env: telegram
- name: Send Telegram message about started deployment
id: sendMsg
run: |
export message_id=$(curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/sendMessage -d chat_id=${{ secrets.TELEGRAM_CHAT }} -d text="🔄 Deployment started for commit ${{ github.sha }}" | jq .result.message_id)
echo "::set-output name=message_id::$message_id"
- uses: actions/checkout@v2
- name: Sentry Release
uses: getsentry/[email protected]
env:
SENTRY_AUTH_TOKEN: ${{ secrets.SENTRY_AUTH_TOKEN }}
SENTRY_ORG: ${{ secrets.SENTRY_ORG }}
SENTRY_PROJECT: ${{ secrets.SENTRY_PROJECT }}
with:
environment: prod
ignore_missing: true
ignore_empty: true
- name: Send request to Watchtower HTTP API
run: 'curl -H "Authorization: Bearer ${{ secrets.WT_TOKEN }}" http://${{ secrets.WT_HOST }}:${{ secrets.WT_PORT }}/v1/update'
- name: Update deployment status
uses: bobheadxi/[email protected]
if: always()
with:
step: finish
token: ${{ secrets.GITHUB_TOKEN }}
status: ${{ job.status }}
deployment_id: ${{ steps.deployment.outputs.deployment_id }}
- name: Edit Telegram message about finished deployment
run: curl https://api.telegram.org/bot${{ secrets.TELEGRAM_TOKEN }}/editMessageText -d chat_id=${{ secrets.TELEGRAM_CHAT }} -d text="✅ Deployment finished for commit ${{ github.sha }}" -d message_id=${{ steps.sendMsg.outputs.message_id }}