name: Docker Image CI/CD

on:
  push:
    branches:
      - master
    paths-ignore:
      - '**/*.md'
  workflow_dispatch:
jobs:
  publish-latest-docker-image:
    runs-on: ubuntu-latest
    name: Build and publish docker image

    steps:
      - name: Checkout
        uses: actions/checkout@v2
      - name: Build image
        run: |
          docker build -t ${{ secrets.DOCKER_HUB_USERNAME }}/astrbot:latest .
      - name: Publish image
        run: |
          docker login -u ${{ secrets.DOCKER_HUB_USERNAME }} -p ${{ secrets.DOCKER_HUB_PASSWORD }}
          docker push ${{ secrets.DOCKER_HUB_USERNAME }}/astrbot:latest
