-
-
Notifications
You must be signed in to change notification settings - Fork 2
100 lines (88 loc) · 3.4 KB
/
ci.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
name: Docker Build
on:
push:
branches:
- main
workflow_dispatch:
schedule:
- cron: "0 0 * * *"
pull_request:
jobs:
build:
name: Build Image
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Checkout current repo
uses: actions/checkout@v3
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Login to DockerHub
uses: docker/login-action@v3
if: github.event_name != 'pull_request'
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout telegram-bot-api repo
uses: actions/checkout@v3
with:
repository: tdlib/telegram-bot-api
path: telegram-bot-api
submodules: recursive
- name: Set ENV Variables
run: |
IMG="$(echo "${{ github.repository }}" | tr '[:upper:]' '[:lower:]')"
telegram_bot_api_revision=$(cd telegram-bot-api && git rev-parse --short HEAD)
tg_server_version=$(cat telegram-bot-api/CMakeLists.txt | grep TelegramBotApi | cut -d " " -f3)
echo "BUILD_VER=$tg_server_version-$telegram_bot_api_revision" >> $GITHUB_ENV
echo "IMAGE=${IMG}" >> $GITHUB_ENV
echo "BUILD_DATE=$(date +'%Y-%m-%d %H:%M:%S')" >> $GITHUB_ENV
echo "GIT_SHA=$(echo ${{ github.sha }} | cut -c1-7)" >> $GITHUB_ENV
echo "GIT_REF=$(git symbolic-ref -q --short HEAD || git describe --tags --exact-match)" >> $GITHUB_ENV
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Build and push
id: docker_build
uses: docker/build-push-action@v5
with:
context: .
platforms: linux/amd64,linux/arm64
push: ${{ github.event_name != 'pull_request' }}
cache-from: type=gha
cache-to: type=gha,mode=max
tags: |
ghcr.io/${{ env.IMAGE }}:latest
ghcr.io/${{ env.IMAGE }}:${{ env.BUILD_VER }}
${{ env.IMAGE }}:latest
${{ env.IMAGE }}:${{ env.BUILD_VER }}
labels: |
org.opencontainers.image.authors=${{ github.repository_owner }}
org.opencontainers.image.created=${{ env.BUILD_DATE }}
org.opencontainers.image.description=Created from commit ${{ env.GIT_SHA }} and ref ${{ env.GIT_REF }}
org.opencontainers.image.ref.name=${{ env.GIT_REF }}
org.opencontainers.image.revision=${{ github.sha }}
org.opencontainers.image.source=https://github.com/${{ github.repository }}
org.opencontainers.image.version=${{ env.BUILD_VER }}
update-description:
name: Update DockerHub Description
runs-on: ubuntu-latest
needs: build
steps:
- uses: actions/checkout@v3
- name: Docker Hub Description
uses: peter-evans/dockerhub-description@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_PASSWORD }}
automerge-dependabot-pr:
needs: build
uses: divkix/reusable-workflows/.github/workflows/automerge-dependabot-pr.yml@main