refactor: 引入 gorm 框架,规范数据库 CRUD 流程 #38
This file contains hidden or 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 Docker Image | |
| on: | |
| push: | |
| branches: ["**"] | |
| workflow_dispatch: | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout | |
| uses: actions/checkout@v4 | |
| - name: Setup Node | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| - name: Install pnpm | |
| run: npm install -g pnpm@latest-10 | |
| - name: Setup Go | |
| uses: actions/setup-go@v5 | |
| with: | |
| go-version: '1.23.x' | |
| # - name: Build Backend Project | |
| # run: | | |
| # chmod +x ./build.sh | |
| # ./build.sh | |
| - name: Prepare image tags | |
| run: | | |
| TAG_BRANCH=${GITHUB_REF_NAME//\//-} | |
| SHORT_SHA=${GITHUB_SHA::6} | |
| echo "IMAGE_TAG=${TAG_BRANCH}-${SHORT_SHA}" >> "$GITHUB_ENV" | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKER_USERNAME }} | |
| password: ${{ secrets.DOCKER_PASSWORD }} | |
| - name: Build and push Docker image | |
| env: | |
| IMAGE_TAG: ${{ env.IMAGE_TAG }} | |
| run: | | |
| docker build -t "${{ vars.IMAGE_REPO}}:$IMAGE_TAG" -t "${{ vars.IMAGE_REPO}}:latest" -f "./Dockerfile" . | |
| docker push "${{ vars.IMAGE_REPO}}:$IMAGE_TAG" | |
| docker push "${{ vars.IMAGE_REPO}}:latest" |