Skip to content

dockerimage

dockerimage #119

Workflow file for this run

name: dockerimage
on:
push:
branches:
- main
tags:
- 'v*'
schedule:
# * is a special character in YAML so you have to quote this string
# At 04:00 on Sunday
# https://crontab.guru/#0_4_*_*_0
- cron: "0 4 * * 0"
workflow_dispatch: # Allow manual triggering
jobs:
build:
runs-on: ubuntu-latest
timeout-minutes: 15
steps:
- name: Env
run: |
env | sort
- uses: actions/checkout@v4
with:
lfs: true
submodules: true
- name: Prepare
id: prep
run: |
DOCKER_IMAGE=ghcr.io/andromedarabbit/readwise-telegram-bot
VERSION=edge
if [[ "${{ github.event_name }}" == "schedule" ]]; then
VERSION=nightly
elif [[ "${{ github.event_name }}" != "pull_request" ]]; then
VERSION=${GITHUB_REF#refs/heads/}
else
VERSION=${GITHUB_HEAD_REF}
fi
VERSION=${VERSION/\//-}
TAGS="${DOCKER_IMAGE}:${VERSION}"
if [[ "${VERSION}" == "main" ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
if [[ $GITHUB_REF == refs/tags/* ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:${GITHUB_REF#refs/tags/v}"
fi
SHORT_ID=$(echo ${GITHUB_SHA} | cut -c -7)
TAGS="$TAGS,${DOCKER_IMAGE}:sha-${SHORT_ID}"
if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then
TAGS="$TAGS,${DOCKER_IMAGE}:latest"
fi
echo "tags=${TAGS}" >>$GITHUB_OUTPUT
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
- name: Test
run: |
set -x
docker version
docker buildx version
docker buildx ls
- name: Login to GitHub Container Registry
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.repository_owner }}
password: ${{ secrets.GITHUB_TOKEN }}
# - name: Start SSH via Ngrok
# # if: ${{ failure() }}
# run: |
# curl -sL https://gist.github.com/andromedarabbit/4aa58f257d05014f5cf543ebfa7188db/raw/9d0935bbfc3c63d81f4f265f355c0f5d265c2fce/debug-github-actions.sh | bash
# env:
# # After sign up on the https://ngrok.com/
# # You can fin this token here: https://dashboard.ngrok.com/get-started/setup
# NGROK_TOKEN: ${{ secrets.NGROK_TOKEN }}
# # This password you will use when authorizing via SSH
# USER_PASS: ${{ secrets.USER_PASS }}
# USER: runner
# - name: Don't kill instace
# # if: ${{ failure() }}
# run: sleep 1h
- uses: docker/build-push-action@v5
with:
file: ${{ github.workspace }}/Dockerfile
context: ${{ github.workspace }}
platforms: linux/amd64,linux/arm64
tags: ${{ steps.prep.outputs.tags }}
pull: true
push: true
cache-from: type=gha
cache-to: type=gha,mode=max