Skip to content

Commit

Permalink
feat: github action matrix for images build (#4712)
Browse files Browse the repository at this point in the history
* feat: github action matrix images build

Signed-off-by: hungran <[email protected]>

* naming for each CI should be more visible, add matrix for build_tool image base

Signed-off-by: hungran <[email protected]>

* adding configuration for matrix container registry

Signed-off-by: hungran <[email protected]>

* docker tag with matrix container registry

Signed-off-by: hungran <[email protected]>

---------

Signed-off-by: hungran <[email protected]>
  • Loading branch information
hungran authored Dec 14, 2023
1 parent 4396fb7 commit fa62482
Show file tree
Hide file tree
Showing 5 changed files with 66 additions and 98 deletions.
61 changes: 26 additions & 35 deletions .github/workflows/build_tool.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: build
name: build_tool

on:
pull_request:
Expand All @@ -13,45 +13,36 @@ env:
jobs:
tool:
runs-on: ubuntu-latest
strategy:
matrix:
image:
- actions-gh-release
- actions-plan-preview
- codegen
- piped-base
- piped-base-okd
- firestore-emulator
include:
- image: actions-gh-release
context: tool/actions-gh-release
- image: actions-plan-preview
context: tool/actions-plan-preview
- image: codegen
context: tool/codegen
- image: piped-base
context: tool/piped-base
- image: piped-base-okd
context: tool/piped-base-okd
- image: firestore-emulator
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Determine version
run: echo "PIPECD_VERSION=$(git describe --tags --always --abbrev=7)" >> $GITHUB_ENV

- name: Build actions-gh-release image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
- name: Build ${{ matrix.image }} image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5.0.0
with:
context: tool/actions-gh-release
tags: ${{ env.REGISTRY }}/pipe-cd/actions-gh-release:${{ env.PIPECD_VERSION }}

- name: Build actions-plan-preview image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: tool/actions-plan-preview
tags: ${{ env.REGISTRY }}/pipe-cd/actions-plan-preview:${{ env.PIPECD_VERSION }}

- name: Build codegen image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: tool/codegen
tags: ${{ env.REGISTRY }}/pipe-cd/codegen:${{ env.PIPECD_VERSION }}

- name: Build piped-base image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: tool/piped-base
tags: ${{ env.REGISTRY }}/pipe-cd/piped-base:${{ env.PIPECD_VERSION }}

- name: Build piped-base-okd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: tool/piped-base-okd
tags: ${{ env.REGISTRY }}/pipe-cd/piped-base-okd:${{ env.PIPECD_VERSION }}

- name: Build firestore-emulator image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
context: tool/firestore-emulator
tags: ${{ env.REGISTRY }}/pipe-cd/firestore-emulator:${{ env.PIPECD_VERSION }}
context: ${{ matrix.context }}
tags: ${{ env.REGISTRY }}/pipe-cd/${{ matrix.image }}:${{ env.PIPECD_VERSION }}
97 changes: 37 additions & 60 deletions .github/workflows/publish_image_chart.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish
name: publish_image_chart

on:
push:
Expand All @@ -20,6 +20,37 @@ jobs:
permissions:
contents: read
packages: write
strategy:
matrix:
image:
- helloworld
- launcher
- launcher-okd
- pipecd
- piped
- piped-okd
- pipectl
container_registry:
- ghcr.io
include:
- image: helloworld
dockerfile: cmd/helloworld/Dockerfile
container_registry: gcr.io
- image: launcher
dockerfile: cmd/launcher/Dockerfile
container_registry: gcr.io
- image: launcher-okd
dockerfile: cmd/launcher/Dockerfile-okd
- image: pipecd
dockerfile: cmd/pipecd/Dockerfile
container_registry: gcr.io
- image: piped
dockerfile: cmd/piped/Dockerfile
- image: piped-okd
dockerfile: cmd/piped/Dockerfile-okd
- image: pipectl
dockerfile: cmd/pipectl/Dockerfile

steps:
- uses: actions/checkout@v3
with:
Expand Down Expand Up @@ -76,69 +107,15 @@ jobs:
password: ${{ secrets.GCR_SA }}

# Building and pushing container images.
- name: Build and push pipecd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/pipecd/Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ env.GHCR }}/pipe-cd/pipecd:${{ env.PIPECD_VERSION }}
- name: Build and push piped image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/piped/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.GHCR }}/pipe-cd/piped:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/piped:${{ env.PIPECD_VERSION }}
- name: Build and push piped-okd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/piped/Dockerfile-okd
platforms: linux/amd64,linux/arm64
tags: ${{ env.GHCR }}/pipe-cd/piped-okd:${{ env.PIPECD_VERSION }}
- name: Build and push launcher image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
- name: Build and push ${{ matrix.image }} image
uses: docker/build-push-action@0565240e2d4ab88bba5387d719585280857ece09 #v5.0.0
with:
push: true
context: .
file: cmd/launcher/Dockerfile
file: ${{ matrix.dockerfile }}
platforms: linux/amd64,linux/arm64
tags: |
${{ env.GHCR }}/pipe-cd/launcher:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/launcher:${{ env.PIPECD_VERSION }}
- name: Build and push launcher-okd image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/launcher/Dockerfile-okd
platforms: linux/amd64,linux/arm64
tags: ${{ env.GHCR }}/pipe-cd/launcher-okd:${{ env.PIPECD_VERSION }}
- name: Build and push pipectl image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/pipectl/Dockerfile
platforms: linux/amd64,linux/arm64
tags: ${{ env.GHCR }}/pipe-cd/pipectl:${{ env.PIPECD_VERSION }}
- name: Build and push helloworld image
uses: docker/build-push-action@ad44023a93711e3deb337508980b4b5e9bcdc5dc
with:
push: true
context: .
file: cmd/helloworld/Dockerfile
platforms: linux/amd64,linux/arm64
tags: |
${{ env.GHCR }}/pipe-cd/helloworld:${{ env.PIPECD_VERSION }}
${{ env.GCR }}/pipecd/helloworld:${{ env.PIPECD_VERSION }}
tags: ${{ matrix.container_registry }}/pipe-cd/${{ matrix.image }}:${{ env.PIPECD_VERSION }}

# Building and pushing Helm charts.
- name: Install helm
uses: Azure/setup-helm@v1
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_site.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish
name: publish_site

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/publish_tool.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: publish
name: publish_tool

on:
push:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_tool.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: test
name: test_tool

on:
push:
Expand Down

0 comments on commit fa62482

Please sign in to comment.