diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 0911c24..5cc84ef 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -46,19 +46,32 @@ jobs: uses: actions/checkout@v4 - name: Log in to GitHub Container Registry - if: ${{ github.event.label.name == 'build' }} + if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }} run: echo "${{ secrets.GITHUB_TOKEN }}" | docker login ghcr.io -u ${{ github.actor }} --password-stdin - name: Build and push to ghcr - if: ${{ github.event.label.name == 'build' }} + if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }} run: | TAG="pr-${{ github.event.pull_request.number }}-$(git rev-parse --short HEAD)" + echo "TAG=${TAG}" >> $GITHUB_ENV docker build -t ghcr.io/camptocamp/pg253:${TAG} \ --pull --no-cache \ --label GIT_COMMIT=$(git rev-parse HEAD) . docker push ghcr.io/camptocamp/pg253:${TAG} + - uses: actions/github-script@v7 + if: ${{ contains( github.event.pull_request.labels.*.name, 'build') }} + with: + github-token: ${{secrets.GITHUB_TOKEN}} + script: | + github.rest.issues.createComment({ + issue_number: context.issue.number, + owner: context.repo.owner, + repo: context.repo.repo, + body: "A docker image was successfully build for your Pull Request: `ghcr.io/camptocamp/pg253:${TAG}`" + }) + - name: Build only - if: ${{ github.event.label.name != 'build' }} + if: ${{ not contains( github.event.pull_request.labels.*.name, 'build') }} run: | docker build --pull --no-cache .