46 lines
1.4 KiB
YAML
46 lines
1.4 KiB
YAML
name: Publish Docker image
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
tags:
|
|
- 'v*.*.*'
|
|
workflow_dispatch:
|
|
|
|
permissions:
|
|
contents: read
|
|
packages: write
|
|
|
|
env:
|
|
FORCE_JAVASCRIPT_ACTIONS_TO_NODE24: true
|
|
|
|
jobs:
|
|
publish:
|
|
runs-on: ubuntu-latest
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Login to GHCR
|
|
run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u "${{ github.actor }}" --password-stdin
|
|
- name: Build image
|
|
run: |
|
|
IMAGE=ghcr.io/${{ github.repository_owner }}/guko
|
|
TAGS="-t $IMAGE:${{ github.sha }}"
|
|
if [ "${{ github.ref_type }}" = "branch" ] && [ "${{ github.ref_name }}" = "main" ]; then
|
|
TAGS="$TAGS -t $IMAGE:latest"
|
|
fi
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
TAGS="$TAGS -t $IMAGE:${{ github.ref_name }} -t $IMAGE:latest"
|
|
fi
|
|
docker build -f telegram-bot/Dockerfile $TAGS .
|
|
- name: Push image
|
|
run: |
|
|
IMAGE=ghcr.io/${{ github.repository_owner }}/guko
|
|
docker push "$IMAGE:${{ github.sha }}"
|
|
if [ "${{ github.ref_type }}" = "branch" ] && [ "${{ github.ref_name }}" = "main" ]; then
|
|
docker push "$IMAGE:latest"
|
|
fi
|
|
if [ "${{ github.ref_type }}" = "tag" ]; then
|
|
docker push "$IMAGE:${{ github.ref_name }}"
|
|
docker push "$IMAGE:latest"
|
|
fi
|