From 6583b501bb967e97f0abd6f8f69cb742a0148a01 Mon Sep 17 00:00:00 2001 From: Jonas Bostoen Date: Fri, 17 Jan 2025 12:09:59 +0100 Subject: [PATCH] ci: docker build cmd wip --- .github/workflows/docker-build-cmd.yml | 56 ++++++++++++++++++++++++++ 1 file changed, 56 insertions(+) create mode 100644 .github/workflows/docker-build-cmd.yml diff --git a/.github/workflows/docker-build-cmd.yml b/.github/workflows/docker-build-cmd.yml new file mode 100644 index 000000000..ca138d2b5 --- /dev/null +++ b/.github/workflows/docker-build-cmd.yml @@ -0,0 +1,56 @@ +# .github/workflows/docker-build-on-comment.yml +name: Build Docker Image on Comment + +on: + issue_comment: + types: [created] + +jobs: + build: + if: | + github.event.issue.pull_request != null && + startsWith(github.event.comment.body, '/build ') + runs-on: ubuntu-latest + + steps: + - name: Extract subdirectory and tag from comment + id: extract + run: | + echo "Comment: ${{ github.event.comment.body }}" + if [[ "${{ github.event.comment.body }}" =~ ^/build[[:space:]]+([^:]+):(.+)$ ]]; then + echo "subdir=${BASH_REMATCH[1]}" >> $GITHUB_ENV + echo "tag=${BASH_REMATCH[2]}" >> $GITHUB_ENV + else + echo "Comment does not match the expected pattern." + exit 1 + fi + + - name: Checkout PR code + uses: actions/checkout@v3 + with: + ref: ${{ github.event.issue.pull_request.head.ref }} + + # - name: Set up Docker Buildx + # uses: docker/setup-buildx-action@v2 + + # - name: Log in to GitHub Container Registry + # uses: docker/login-action@v2 + # with: + # registry: ghcr.io + # username: ${{ github.actor }} + # password: ${{ secrets.GITHUB_TOKEN }} + + # - name: Build and push Docker image + # uses: docker/build-push-action@v4 + # with: + # context: ./${{ env.subdir }} + # push: true + # tags: ghcr.io/${{ github.repository_owner }}/${{ env.subdir }}:${{ env.tag }} + + - name: Post comment on PR + uses: thollander/actions-comment-pull-request@v1 + with: + message: | + The Docker image has been successfully built and pushed to GHCR. + Image: `ghcr.io/${{ github.repository_owner }}/${{ env.subdir }}:${{ env.tag }}` + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file