Skip to content

Commit

Permalink
Merge pull request #135 from sp-yduck/improve/ci
Browse files Browse the repository at this point in the history
support chat command for ci workflow
  • Loading branch information
sp-yduck authored Nov 11, 2023
2 parents 137744f + ebc6935 commit eeef485
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 4 deletions.
17 changes: 16 additions & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,20 @@ on:
push:
branches:
- main
issue_comment:
types: [created, edited]

env:
REGISTRY: docker.io
IMAGE_NAME: spyduck/cluster-api-provider-proxmox
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

jobs:
# add public code coverage reports
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"
Expand All @@ -23,6 +27,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
Expand All @@ -33,5 +38,15 @@ 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}"
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 }})"
6 changes: 3 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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=<myregistry/image:<tag>> 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
Expand Down

0 comments on commit eeef485

Please sign in to comment.