More one line log and simplify the worker logic #18 (#21) #7
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: build-and-push-scheduler | |
env: | |
DOCKER_HUB_USERNAME: tuana9a | |
IMAGE_NAME: tuana9a/dkhptd-scheduler | |
on: | |
push: | |
branches: | |
- "main" | |
paths: | |
- "scheduler/**" | |
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: ./scheduler | |
file: ./scheduler/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 }}\" | |
}" |