From eaa995a1aa3e2d26ada186602e4a516317349ecb Mon Sep 17 00:00:00 2001 From: Lukasz Raczylo Date: Mon, 28 Dec 2020 09:48:01 +0000 Subject: [PATCH] Update README --- .github/workflows/build_image.yml | 45 ++++++++++++++++++++++++++----- 1 file changed, 38 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build_image.yml b/.github/workflows/build_image.yml index 6e0c017..eeb141c 100644 --- a/.github/workflows/build_image.yml +++ b/.github/workflows/build_image.yml @@ -32,10 +32,41 @@ jobs: uses: docker/setup-buildx-action@v1 - name: Build Docker image run: | - cd /home/runner/work/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api-docker/tdlib-telegram-bot-api - export SET_DOCKER_REGISTRY="docker.pkg.github.com" - export BASE_IMG_NAME="$SET_DOCKER_REGISTRY/lukaszraczylo/tdlib-telegram-bot-api-docker/telegram-api-server" - docker login $SET_DOCKER_REGISTRY -u "${{ github.actor }}" -p "${{ secrets.GITHUB_TOKEN }}" - docker buildx build --platform linux/arm64,linux/amd64 -t $BASE_IMG_NAME:${{ env.GITHUB_SHA }} -t $BASE_IMG_NAME:1.0.${{ env.GITHUB_RUN_ID }} -t $BASE_IMG_NAME:latest . - docker push "$BASE_IMG_NAME" - docker push "$BASE_IMG_NAME:latest" \ No newline at end of file + 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 + TAGS="$TAGS,$DOCKER_IMAGE:${{ env.GITHUB_SHA }},$DOCKER_IMAGE:1.0.${{ env.GITHUB_RUN_ID }},$DOCKER_IMAGE:latest" + 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 + 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 }}