From 7d522e5f73b433fc3677a59dbb3c8cc3a42640f9 Mon Sep 17 00:00:00 2001 From: kislovdm Date: Sat, 11 Apr 2026 10:39:02 +0300 Subject: [PATCH] build actions --- .github/workflows/docker-publish.yml | 75 ++++++++++++++++++++++++++++ 1 file changed, 75 insertions(+) create mode 100644 .github/workflows/docker-publish.yml diff --git a/.github/workflows/docker-publish.yml b/.github/workflows/docker-publish.yml new file mode 100644 index 0000000..996b3a5 --- /dev/null +++ b/.github/workflows/docker-publish.yml @@ -0,0 +1,75 @@ +# Сборка образа и публикация на Docker Hub (hub.docker.com). +# +# Настройка в GitHub → Settings → Secrets and variables → Actions: +# DOCKERHUB_USERNAME — логин Docker Hub +# DOCKERHUB_TOKEN — Access Token (рекомендуется), см. https://hub.docker.com/settings/security +# +# Опционально: Variables → DOCKERHUB_IMAGE (например org/max2telegram), если имя образа +# отличается от /max2telegram. + +name: Docker Hub + +on: + push: + branches: + - main + - master + tags: + - 'v*' + workflow_dispatch: + +concurrency: + group: docker-hub-${{ github.ref }} + cancel-in-progress: true + +permissions: + contents: read + actions: write # кэш слоёв Buildx (type=gha) + +jobs: + build-and-push: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v4 + + - name: Set image name + id: image + run: | + if [ -n "${{ vars.DOCKERHUB_IMAGE }}" ]; then + echo "name=${{ vars.DOCKERHUB_IMAGE }}" >> "$GITHUB_OUTPUT" + else + echo "name=${{ secrets.DOCKERHUB_USERNAME }}/max2telegram" >> "$GITHUB_OUTPUT" + fi + + - name: Docker Hub login + uses: docker/login-action@v3 + with: + username: ${{ secrets.DOCKERHUB_USERNAME }} + password: ${{ secrets.DOCKERHUB_TOKEN }} + + - name: Set up Buildx + uses: docker/setup-buildx-action@v3 + + - name: Docker metadata (теги) + id: meta + uses: docker/metadata-action@v5 + with: + images: ${{ steps.image.outputs.name }} + tags: | + type=ref,event=branch + type=semver,pattern={{version}} + type=semver,pattern={{major}}.{{minor}} + type=sha,prefix= + type=raw,value=latest,enable={{is_default_branch}} + + - name: Build and push + uses: docker/build-push-action@v6 + with: + context: . + file: ./Dockerfile + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} + cache-from: type=gha + cache-to: type=gha,mode=max