name: Docker-CICD
on:
  push:
    branches: [main]
  workflow_dispatch:
jobs:
  build:
    name: Build
    runs-on: ubuntu-latest
    steps:
      - name: Check out branch
        uses: actions/checkout@v2
      - name: Login to Aliyun Registry
        uses: docker/login-action@v1
        with:
          registry: ${{ secrets.ALIYUN_REGISTRY }}
          username: ${{ secrets.ALIYUN_DOCKERHUB_USER }}
          password: ${{ secrets.ALIYUN_DOCKERHUB_PASSWORD }}
      - name: Sed Config
        shell: bash
        run: |
          sed -i 's#./entrypoint.sh"#./entrypoint.sh","actions"#g' Dockerfile
          sed -i "s#COPY build/ /usr/share/nginx/html/#COPY . /opt/gva#g" Dockerfile
          sed  -i 16c"\    && cd /opt/gva/server/ && go mod tidy && cd /opt/gva/web/ && yarn" Dockerfile
          sed -i "s#open: true#open: false#g" web/vite.config.js
          make images TAGS_OPT="latest"
          docker push registry.cn-hangzhou.aliyuncs.com/gva/web:latest
          docker push registry.cn-hangzhou.aliyuncs.com/gva/server:latest
          docker push registry.cn-hangzhou.aliyuncs.com/gva/all:latest
