fix: 修复工作流触发条件,确保在推送和拉取请求时正确监控相关文件 #31
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" ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/docker-image.yml' | |
| - 'main.py' | |
| - 'requirements.txt' | |
| - 'app/**' | |
| tags: | |
| - 'v*' | |
| pull_request: | |
| branches: [ "master" ] | |
| paths: | |
| - 'Dockerfile' | |
| - '.github/workflows/docker-image.yml' | |
| - 'main.py' | |
| - 'requirements.txt' | |
| - 'app/**' | |
| permissions: | |
| contents: read | |
| 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) }} |