From 343653aabacaf6aed99ba5e758632eba5d3f4f72 Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 11 Nov 2023 12:30:07 +0900 Subject: [PATCH 1/2] support chat command for ci workflow --- .github/workflows/ci.yaml | 7 ++++++- Makefile | 6 +++--- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 056f687..163804d 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -4,6 +4,8 @@ on: push: branches: - main + issue_comment: + types: [created, edited] env: REGISTRY: docker.io @@ -14,6 +16,7 @@ jobs: coverage: name: unit test coverage runs-on: ubuntu-latest + if: github.event_name == "push" || contains(github.event.comment.body, "/unit-test") steps: - uses: actions/checkout@master - run: "make unit-test-cover" @@ -23,6 +26,7 @@ jobs: build: name: docker build & push runs-on: ubuntu-latest + if: github.event_name == "push" || contains(github.event.comment.body, "/buid-push") steps: - name: Checkout repository uses: actions/checkout@v4 @@ -33,5 +37,6 @@ jobs: username: ${{ secrets.DOCKER_USERNAME }} password: ${{ secrets.DOCKER_PASSWORD }} + # platform = linux/amd64,linux/arm64 - name: Build and push Docker image - run: "make docker-build docker-push IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_SHA::7}" \ No newline at end of file + run: "make docker-buildx IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_SHA::7}" \ No newline at end of file diff --git a/Makefile b/Makefile index edc7c00..a986f95 100644 --- a/Makefile +++ b/Makefile @@ -143,7 +143,7 @@ run: manifests generate fmt vet ## Run a controller from your host. # (i.e. docker build --platform linux/arm64 ). However, you must enable docker buildKit for it. # More info: https://docs.docker.com/develop/develop-images/build_enhancements/ .PHONY: docker-build -docker-build: # test ## Build docker image with the manager. +docker-build: unit-test ## Build docker image with the manager. docker build -t ${IMG} . .PHONY: docker-push @@ -156,9 +156,9 @@ docker-push: ## Push docker image with the manager. # - have enable BuildKit, More info: https://docs.docker.com/develop/develop-images/build_enhancements/ # - be able to push the image for your registry (i.e. if you do not inform a valid value via IMG=> then the export will fail) # To properly provided solutions that supports more than one platform you should use this option. -PLATFORMS ?= linux/arm64,linux/amd64,linux/s390x,linux/ppc64le +PLATFORMS ?= linux/arm64,linux/amd64 #,linux/s390x,linux/ppc64le .PHONY: docker-buildx -docker-buildx: test ## Build and push docker image for the manager for cross-platform support +docker-buildx: ## Build and push docker image for the manager for cross-platform support # copy existing Dockerfile and insert --platform=${BUILDPLATFORM} into Dockerfile.cross, and preserve the original Dockerfile sed -e '1 s/\(^FROM\)/FROM --platform=\$$\{BUILDPLATFORM\}/; t' -e ' 1,// s//FROM --platform=\$$\{BUILDPLATFORM\}/' Dockerfile > Dockerfile.cross - docker buildx create --name project-v3-builder From ebc693521e86a44ca24a0cc09a99165818c1414f Mon Sep 17 00:00:00 2001 From: sp-yduck Date: Sat, 11 Nov 2023 13:30:29 +0900 Subject: [PATCH 2/2] report result as pr comment --- .github/workflows/ci.yaml | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 163804d..bc13f0c 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -10,6 +10,7 @@ on: env: REGISTRY: docker.io IMAGE_NAME: spyduck/cluster-api-provider-proxmox + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} jobs: # add public code coverage reports @@ -39,4 +40,13 @@ jobs: # platform = linux/amd64,linux/arm64 - name: Build and push Docker image - run: "make docker-buildx IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_SHA::7}" \ No newline at end of file + run: "make docker-buildx IMG=${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${GITHUB_SHA::7}" + + # report result to pr comment if event is pr comment + result: + name: report to pr comment + runs-on: ubunt-latest + if: github.event_name == "issue_comment" && ${{ github.event.issue.pull_request }} + steps: + - run: | + gh pr comment ${{ github.event.issue.number }} -b "[Actions: CI] Check result [here](https://github.com/sp-yduck/cluster-api-provider-proxmox/actions/runs/${{ github.run_number }})" \ No newline at end of file