name: docker-alpine-epusdt

on:
  workflow_dispatch:
  push:
    branches:
      - "main"

env:
  IMAGE_NAME: epusdt

jobs:
  push-docker-hub:
    runs-on: ubuntu-latest
    env:
      TZ: Asia/Shanghai

    steps:
      - uses: actions/checkout@v6

      - name: Compute Build Metadata
        id: meta
        shell: bash
        run: |
          echo "version=main-${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
          echo "commit=${GITHUB_SHA}" >> "$GITHUB_OUTPUT"
          echo "date=$(date -u +%Y-%m-%dT%H:%M:%SZ)" >> "$GITHUB_OUTPUT"

      - name: Login
        uses: docker/login-action@v3
        with:
          username: ${{ secrets.DOCKERHUB_USERNAME }}
          password: ${{ secrets.DOCKERHUB_TOKEN }}

      - name: Build And Push
        uses: docker/build-push-action@v6
        with:
          context: .
          file: ./Dockerfile
          push: true
          build-args: |
            VERSION=${{ steps.meta.outputs.version }}
            COMMIT=${{ steps.meta.outputs.commit }}
            DATE=${{ steps.meta.outputs.date }}
          tags: |
            ${{ secrets.DOCKERHUB_USERNAME }}/${{ env.IMAGE_NAME }}:alpine
