Skip to content

re-unite

re-unite #4

name: build-and-push-worker
env:
DOCKER_HUB_USERNAME: tuana9a
IMAGE_NAME: tuana9a/dkhptd-worker
on:
push:
branches:
- "main"
paths:
- "worker/**"
jobs:
build-and-push:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ env.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Set docker tags
run: |
echo DOCKER_TAG_MONTHLY=$(date +"%Y.%m") >> $GITHUB_ENV
echo DOCKER_TAG_DAILY=$(date +"%Y.%m.%d") >> $GITHUB_ENV
echo DOCKER_TAG_SECONDLY=$(date +"%Y.%m.%d.%H%M%S") >> $GITHUB_ENV
- name: Build and push
uses: docker/build-push-action@v4
with:
context: ./worker
file: ./worker/Dockerfile
push: true
tags: |
${{ env.IMAGE_NAME }}:latest
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_DAILY }}
${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_MONTHLY }}
cache-from: type=gha
cache-to: type=gha,mode=max
- name: Send notification
if: always()
shell: bash
run: |
curl -X POST https://api.telegram.org/bot${{ secrets.TELEGRAM_BOT_TOKEN }}/sendMessage \
-H "Content-Type: application/json" \
-d "{
\"chat_id\":\"${{ secrets.TELEGRAM_CHAT_ID }}\",
\"disable_notification\":true,
\"text\":\"${{ job.status }} ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}\\nimg: ${{ env.IMAGE_NAME }}:${{ env.DOCKER_TAG_SECONDLY }}\"
}"