refactor: 重构 Docker 镜像 CI 流程,合并构建和推送步骤 #10
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: Docker Image CI | |
| on: | |
| push: | |
| branches: [ "master" ] | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [ "master" ] | |
| jobs: | |
| build-and-push: | |
| runs-on: ubuntu-latest | |
| if: github.event_name != 'pull_request' | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Set up Docker Buildx | |
| uses: docker/setup-buildx-action@v3 | |
| - name: Login to Docker Hub | |
| uses: docker/login-action@v3 | |
| with: | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_TOKEN }} | |
| - name: Build and push | |
| uses: docker/build-push-action@v5 | |
| with: | |
| context: . | |
| push: ${{ github.event_name != 'pull_request' }} | |
| tags: | | |
| e1saps/onebot-github-webhook:latest | |
| ${{ github.event_name == 'push' && startsWith(github.ref, 'refs/tags/') && format('e1saps/onebot-github-webhook:{0}', github.ref_name) || format('e1saps/onebot-github-webhook:{0}', github.sha) }} |