Skip to content

Commit

Permalink
Refactor execution image workflow and action inputs naming.
Browse files Browse the repository at this point in the history
  • Loading branch information
junhaoliao committed Mar 11, 2024
1 parent a61d5e9 commit cd431d0
Show file tree
Hide file tree
Showing 5 changed files with 98 additions and 111 deletions.
34 changes: 17 additions & 17 deletions .github/actions/clp-execution-image-build/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,34 +3,34 @@ description: "Builds a container image that contains the dependencies necessary
to run the CLP package."

inputs:
containerImageRegistry:
image_registry:
default: "ghcr.io"
description: "Container Image Registry"
description: "Container image registry."
required: false
containerImageRegistryUsername:
image_registry_username:
default: "${{github.actor}}"
description: "Container Image Registry Username"
description: "Container image registry username."
required: false
containerImageRegistryPassword:
image_registry_password:
default: ""
description: "Container Image Registry Password"
description: "Container image registry password."
required: false
platformId:
description: "Platform ID of the container. e.g., ubuntu."
platform_id:
description: "Platform ID of the container (e.g. ubuntu)"
required: true
platformVersionId:
description: "Platform VERSION_ID / VERSION_CODENAME of the container.
e.g., jammy, focal."
platform_version_id:
description: "Platform VERSION_ID / VERSION_CODENAME of the container
(e.g. jammy, focal, etc.)"
required: true

runs:
using: "composite"
steps:
- uses: "docker/login-action@v3"
with:
registry: "${{inputs.containerImageRegistry}}"
username: "${{inputs.containerImageRegistryUsername}}"
password: "${{inputs.containerImageRegistryPassword}}"
registry: "${{inputs.image_registry}}"
username: "${{inputs.image_registry_username}}"
password: "${{inputs.image_registry_password}}"

- id: "sanitization"
shell: "bash"
Expand All @@ -43,15 +43,15 @@ runs:
- id: "meta"
uses: "docker/metadata-action@v5"
with:
images: "${{inputs.containerImageRegistry}}/${{steps.sanitization.outputs.REPOSITORY}}\
/clp-execution-x86-${{inputs.platformId}}-${{inputs.platformVersionId}}"
images: "${{inputs.image_registry}}/${{steps.sanitization.outputs.REPOSITORY}}\
/clp-execution-x86-${{inputs.platform_id}}-${{inputs.platform_version_id}}"

- if: "github.event_name != 'pull_request' && github.ref == 'refs/heads/main'"
uses: "docker/build-push-action@v5"
with:
context: "./"
file: "./tools/docker-images/\
clp-execution-base-${{inputs.platformId}}-${{inputs.platformVersionId}}/Dockerfile"
clp-execution-base-${{inputs.platform_id}}-${{inputs.platform_version_id}}/Dockerfile"
push: true
tags: "${{steps.meta.outputs.tags}}"
labels: "${{steps.meta.outputs.labels}}"
78 changes: 78 additions & 0 deletions .github/workflows/clp-execution-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
name: "clp-execution-image-build"

on:
pull_request:
paths:
- ".github/actions/clp-execution-image-build/action.yaml"
- ".github/workflows/clp-execution-image-build.yaml"
- "tools/docker-images/**"
push:
paths:
- ".github/actions/clp-execution-image-build/action.yaml"
- ".github/workflows/clp-execution-image-build.yaml"
- "tools/docker-images/**"
workflow_dispatch:

concurrency:
group: "${{github.workflow}}-${{github.ref}}"
# Cancel in-progress jobs for efficiency
cancel-in-progress: true

jobs:
filter-relevant-changes:
runs-on: "ubuntu-latest"
outputs:
ubuntu_focal_image_changed: "${{steps.filter.outputs.ubuntu_focal_image}}"
ubuntu_jammy_image_changed: "${{steps.filter.outputs.ubuntu_jammy_image}}"
steps:
- uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Work around actions/runner-images/issues/6775"
run: "chown $(id -u):$(id -g) -R ."
shell: "bash"

- name: "Filter relevant changes"
uses: "dorny/paths-filter@v2"
id: "filter"
with:
base: "main"
filters: |
ubuntu_focal_image:
- ".github/actions/**"
- ".github/workflows/clp-execution-image-build.yaml"
- "tools/docker-images/clp-execution-base-ubuntu-focal/**"
ubuntu_jammy_image:
- ".github/actions/**"
- ".github/workflows/clp-execution-image-build.yaml"
- "tools/docker-images/clp-execution-base-ubuntu-jammy/**"
build-image:
needs: "filter-relevant-changes"
runs-on: "ubuntu-latest"
strategy:
matrix:
include:
- platform_version_id: "focal"
condition: "needs.filter-relevant-changes.outputs.ubuntu_focal_image_changed"
- platform_version_id: "jammy"
condition: "needs.filter-relevant-changes.outputs.ubuntu_jammy_image_changed"
steps:
- uses: "actions/checkout@v3"
with:
submodules: "recursive"

- name: "Workaround actions/runner-images/issues/6775"
run: "chown $(id -u):$(id -g) -R ."
shell: "bash"

- name: "Build and Push Docker Image"
if: "'true' == matrix.condition"
uses: "./.github/actions/clp-execution-image-build"
with:
image_registry: "ghcr.io"
image_registry_username: "${{github.actor}}"
image_registry_password: "${{secrets.GITHUB_TOKEN}}"
platform_id: "ubuntu"
platform_version_id: "${{matrix.platform_version_id}}"
41 changes: 0 additions & 41 deletions .github/workflows/clp-execution-image-ubuntu-focal.yaml

This file was deleted.

41 changes: 0 additions & 41 deletions .github/workflows/clp-execution-image-ubuntu-jammy.yaml

This file was deleted.

15 changes: 3 additions & 12 deletions docs/gh-workflows.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,10 @@ need it for one OS since users can use the container on any OS.

This workflow builds CLP-core on macOS and runs its unit tests.

## [clp-execution-image-ubuntu-jammy](../.github/workflows/clp-excution-image-ubuntu-jammy.yaml)
## [clp-execution-image-build](../.github/workflows/clp-execution-image-build.yaml)

This workflow calls
[clp-execution-image-build](../.github/workflows/actions/clp-execution-image-build/action.yaml)
to build a container image that contains the dependencies necessary to run the CLP package on Ubuntu
22.04 (Jammy).

## [clp-execution-image-ubuntu-focal](../.github/workflows/clp-excution-image-ubuntu-focal.yaml)

Similar to
[clp-execution-image-ubuntu-jammy](../.github/workflows/clp-excution-image-ubuntu-jammy.yaml), this
workflow builds a container image that contains the dependencies necessary to run the CLP package on Ubuntu
20.04 (Focal).
This workflow builds a container image that contains the dependencies necessary to run the CLP
package.

## [clp-lint](../.github/workflows/clp-lint.yaml)

Expand Down

0 comments on commit cd431d0

Please sign in to comment.