Files
telegram-bot/.github/workflows/build-image.yml
T
2024-06-06 01:12:29 +03:00

72 lines
2.0 KiB
YAML

name: Build on Push
on:
push:
jobs:
docker:
name: Build Docker image
runs-on: ubuntu-latest
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Registry
uses: docker/login-action@v2
with:
registry: ${{ secrets.REGISTRY_URL }}
username: ${{ secrets.REGISTRY_USERNAME }}
password: ${{ secrets.REGISTRY_PASSWORD }}
-
name: Get short commit SHA
id: commit_sha
run: echo "sha_short=$(git rev-parse --short HEAD)" >> $GITHUB_OUTPUT
-
name: Build and push
uses: docker/build-push-action@v4
with:
platforms: linux/amd64
push: ${{ github.ref == 'refs/heads/dev' }}
tags: ${{ secrets.REGISTRY_URL }}/west/telegram-bot:latest,
${{ secrets.REGISTRY_URL }}/west/telegram-bot:${{ steps.commit_sha.outputs.sha_short }}
cache-from: type=gha
cache-to: type=gha,mode=max
#-
# name: Redeploy container
# uses: fjogeleit/http-request-action@v1
# if: ${{ github.ref == 'refs/heads/dev' }}
# with:
# url: ${{ secrets.CONTAINER_WEBHOOK }}
# method: 'POST'
deploy:
name: Deploy to Kubernetes cluster
runs-on: k8s-route
if: github.ref == 'refs/heads/dev'
steps:
-
name: Checkout source code
uses: actions/checkout@v3
-
name: Configure the Kubernetes context
uses: azure/k8s-set-context@v2
with:
method: service-account
k8s-url: ${{ secrets.KUBERNETES_URL }}
k8s-secret: ${{ secrets.KUBERNETES_SECRET }}
# TODO: looks very unsafe for meed, need review about migrate to GH Action "azure/k8s-deploy"
-
name: Deploy to the Kubernetes cluster
run: |
kubectl -n telegram-bot rollout restart deploy bot