2020-12-27 20:26:00 +03:00
|
|
|
name: Build Telegram API server
|
|
|
|
on:
|
2020-12-27 22:42:54 +03:00
|
|
|
workflow_dispatch:
|
2020-12-27 22:15:53 +03:00
|
|
|
schedule:
|
2020-12-27 22:42:54 +03:00
|
|
|
- cron: "0 2 */7 * *"
|
2020-12-27 20:26:00 +03:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-20.04
|
2020-12-28 12:48:43 +03:00
|
|
|
name: Build amd64 and arm64 images
|
2020-12-27 20:26:00 +03:00
|
|
|
steps:
|
|
|
|
- name: Checkout API repo
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
repository: 'tdlib/telegram-bot-api'
|
|
|
|
path: '/home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api'
|
|
|
|
- name: Checkout Dockerfile
|
|
|
|
uses: actions/checkout@v2
|
|
|
|
with:
|
|
|
|
repository: 'lukaszraczylo/tdlib-telegram-bot-api-docker'
|
|
|
|
path: '/home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/docker'
|
|
|
|
- name: Apply Dockerfile
|
|
|
|
run: |
|
|
|
|
cp /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/docker/Dockerfile /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/Dockerfile
|
|
|
|
- name: Get release sha and run number
|
|
|
|
id: get_sha
|
|
|
|
run: |
|
|
|
|
echo "GITHUB_SHA=$(echo ${GITHUB_SHA::8})" >> $GITHUB_ENV
|
|
|
|
echo "GITHUB_RUN_ID=$(echo ${GITHUB_RUN_NUMBER})" >> $GITHUB_ENV
|
2020-12-27 22:42:54 +03:00
|
|
|
- name: Set up QEMU
|
|
|
|
uses: docker/setup-qemu-action@v1
|
|
|
|
- name: Set up Docker Buildx
|
|
|
|
uses: docker/setup-buildx-action@v1
|
2020-12-28 12:48:43 +03:00
|
|
|
- name: Login to GHCR
|
|
|
|
if: github.event_name != 'pull_request'
|
|
|
|
uses: docker/login-action@v1
|
|
|
|
with:
|
|
|
|
registry: ghcr.io
|
|
|
|
username: ${{ github.actor }}
|
|
|
|
password: ${{ secrets.GCHR_PAT }}
|
|
|
|
- name: Prepare for push
|
|
|
|
id: prep
|
2020-12-27 20:26:00 +03:00
|
|
|
run: |
|
2020-12-28 12:48:01 +03:00
|
|
|
DOCKER_IMAGE=ghcr.io/${{ github.repository_owner }}/tdlib-telegram-bot-api-docker/telegram-api-server
|
|
|
|
VERSION=edge
|
|
|
|
if [[ $GITHUB_REF == refs/tags/* ]]; then
|
|
|
|
VERSION=${GITHUB_REF#refs/tags/v}
|
|
|
|
fi
|
|
|
|
if [ "${{ github.event_name }}" = "schedule" ]; then
|
|
|
|
VERSION=nightly
|
|
|
|
fi
|
|
|
|
TAGS="${DOCKER_IMAGE}:${VERSION}"
|
|
|
|
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
|
|
|
|
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
|
|
|
|
fi
|
2021-04-06 23:20:20 +03:00
|
|
|
TG_API_VERSION=$(grep "project(TelegramBotApi" /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/CMakeLists.txt | awk '{print $3}')
|
|
|
|
TAGS="$TAGS,$DOCKER_IMAGE:${{ env.GITHUB_SHA }},$DOCKER_IMAGE:1.0.${{ env.GITHUB_RUN_ID }},$DOCKER_IMAGE:latest,$DOCKER_IMAGE:api-$TG_API_VERSION"
|
2020-12-28 12:48:01 +03:00
|
|
|
echo ::set-output name=tags::${TAGS}
|
|
|
|
# lowercase the branch name
|
|
|
|
BRANCH=$(echo ${GITHUB_REF##*/} | tr '[A-Z]' '[a-z]')
|
|
|
|
LABELS="org.opencontainers.image.revision=$GITHUB_SHA"
|
|
|
|
LABELS="$LABELS,org.opencontainers.image.created=$(date -u +'%Y-%m-%dT%H:%M:%SZ')"
|
|
|
|
LABELS="$LABELS,org.opencontainers.image.version=$VERSION"
|
|
|
|
LABELS="$LABELS,com.github.repo.branch=$BRANCH"
|
|
|
|
LABELS="$LABELS,com.github.repo.dockerfile=Dockerfile"
|
|
|
|
echo ::set-output name=labels::${LABELS}
|
|
|
|
BUILD_ARGS="BRANCH=$BRANCH"
|
|
|
|
echo ::set-output name=args::${BUILD_ARGS}
|
|
|
|
- name: Tag names
|
|
|
|
run: echo ${{ steps.prep.outputs.tags }}
|
|
|
|
- name: Build and push
|
|
|
|
id: docker_build
|
2022-02-17 00:50:18 +03:00
|
|
|
timeout-minutes: 900
|
2020-12-28 12:48:01 +03:00
|
|
|
uses: docker/build-push-action@v2
|
|
|
|
with:
|
|
|
|
builder: ${{ steps.buildx.outputs.name }}
|
|
|
|
context: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api
|
|
|
|
file: /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api/Dockerfile
|
|
|
|
platforms: linux/arm64,linux/amd64
|
|
|
|
push: ${{ github.event_name != 'pull_request' }}
|
|
|
|
tags: ${{ steps.prep.outputs.tags }}
|
|
|
|
build-args: ${{ steps.prep.outputs.args }}
|
|
|
|
labels: ${{ steps.prep.outputs.labels }}
|
2022-02-17 00:50:18 +03:00
|
|
|
cache-from: type=gha
|
|
|
|
cache-to: type=gha,mode=max
|