-
Notifications
You must be signed in to change notification settings - Fork 26
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Signed-off-by: Sunyanan Choochotkaew <[email protected]>
- Loading branch information
Showing
28 changed files
with
940 additions
and
253 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,84 +1,110 @@ | ||
name: BuildPushDeployImage | ||
name: Build-Push Kepler Model Server Image | ||
|
||
on: | ||
push: | ||
branches: [ main ] | ||
workflow_call: | ||
secrets: | ||
docker_username: | ||
description: 'Docker username' | ||
required: false | ||
docker_password: | ||
description: 'Docker password' | ||
required: false | ||
inputs: | ||
base_change: | ||
description: 'Change flag on base image' | ||
required: true | ||
type: string | ||
image_repo: | ||
description: 'The image repo to use' | ||
required: true | ||
type: string | ||
image_tag: | ||
description: 'The image tag to use' | ||
required: true | ||
type: string | ||
push: | ||
description: 'Push image' | ||
required: false | ||
type: string | ||
default: false | ||
|
||
env: | ||
base_change: ${{ inputs.base_change }} | ||
base_image: ${{ inputs.image_repo }}/kepler_model_server_base:${{ inputs.image_tag }} | ||
image: ${{ inputs.image_repo }}/kepler_model_server:${{ inputs.image_tag }} | ||
|
||
jobs: | ||
|
||
changes: | ||
check-secret: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
src: ${{ steps.changes.outputs.src }} | ||
available: ${{ steps.check-secret.outputs.available }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v2 | ||
id: changes | ||
with: | ||
filters: | | ||
src: | ||
- 'dockerfiles/requirements.txt' | ||
- 'dockerfiles/Dockerfile.base' | ||
- '.github/workflows/build-push.yml' | ||
- name: Check Secret | ||
id: check-secret | ||
env: | ||
SECRET: ${{ secrets.docker_password }} | ||
run: | | ||
if [ "$SECRET" == "" ]; then | ||
echo "available=false" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "available=true" >> "$GITHUB_OUTPUT" | ||
fi | ||
buildbase: | ||
needs: changes | ||
if: ${{ needs.changes.outputs.src == 'true' }} | ||
check-base-exist: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
exists: ${{ steps.check-base-exist.outputs.exists }} | ||
|
||
steps: | ||
- name: Check if Docker base image exists | ||
id: check-base-exist | ||
run: | | ||
if docker pull ${{ env.base_image }}; then | ||
echo "exists=true" >> "$GITHUB_OUTPUT" | ||
else | ||
echo "exists=false" >> "$GITHUB_OUTPUT" | ||
fi | ||
build-base: | ||
runs-on: ubuntu-latest | ||
needs: [check-secret, check-base-exist] | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- name: set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Quay | ||
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }} | ||
- name: Login to Docker | ||
if: ${{ needs.check-secret.outputs.available == 'true' }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io/sustainable_computing_io | ||
username: ${{ secrets.BOT_NAME }} | ||
password: ${{ secrets.BOT_TOKEN }} | ||
- name: Build and push base image | ||
registry: ${{ inputs.image_repo }} | ||
username: ${{ secrets.docker_username }} | ||
password: ${{ secrets.docker_password }} | ||
- name: Build-push base image | ||
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: dockerfiles | ||
platforms: linux/amd64 | ||
push: true | ||
tags: quay.io/sustainable_computing_io/kepler_model_server_base:v0.7 | ||
tags: ${{ env.base_image }} | ||
file: dockerfiles/Dockerfile.base | ||
- name: Build and push Docker image | ||
- name: Replace value in file | ||
if: ${{ (needs.check-secret.outputs.available == 'true') && ((needs.check-base-exist.outputs.exists == 'false') || (env.base_change == 'true')) }} | ||
run: | | ||
sed -i "s|quay.io/sustainable_computing_io/kepler_model_server_base:v0.7|${{ env.base_image }}|" dockerfiles/Dockerfile | ||
- name: Build-push image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
tags: quay.io/sustainable_computing_io/kepler_model_server:latest,quay.io/sustainable_computing_io/kepler_model_server:v0.7 | ||
file: dockerfiles/Dockerfile | ||
|
||
build: | ||
needs: [changes] | ||
if: ${{ needs.changes.outputs.src == 'false' }} | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v4 | ||
- name: set up QEMU | ||
uses: docker/setup-qemu-action@v3 | ||
- name: set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Login to Quay | ||
if: ${{ (github.repository_owner == 'sustainable-computing-io') && (github.ref == 'refs/heads/main') }} | ||
uses: docker/login-action@v3 | ||
with: | ||
registry: quay.io/sustainable_computing_io | ||
username: ${{ secrets.BOT_NAME }} | ||
password: ${{ secrets.BOT_TOKEN }} | ||
- name: Build and push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
context: . | ||
platforms: linux/amd64 | ||
push: true | ||
tags: quay.io/sustainable_computing_io/kepler_model_server:latest,quay.io/sustainable_computing_io/kepler_model_server:v0.7 | ||
push: ${{ inputs.push }} | ||
tags: ${{ env.image }} | ||
file: dockerfiles/Dockerfile |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
# Workflow on Push | ||
# - unit test | ||
# - build image (push if docker-secret exists) | ||
# - collect data (if aws-secret exists) | ||
# - train model (if aws-secret exists) | ||
|
||
name: Workflow on PR | ||
|
||
on: | ||
branch_protection_rule: | ||
pull_request: | ||
paths-ignore: | ||
- 'fig/**' | ||
- '.github/ISSUE_TEMPLATE/**' | ||
- '.vscode/**' | ||
- 'LICENSE' | ||
- '.gitignore' | ||
- '*.md' | ||
- '**/*.md' | ||
|
||
jobs: | ||
check-change: | ||
runs-on: ubuntu-latest | ||
|
||
outputs: | ||
base-change: ${{ steps.base-change.outputs.src }} | ||
data-change: ${{ steps.data-change.outputs.src }} | ||
modeling-change: ${{ steps.modeling-change.outputs.src }} | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: dorny/paths-filter@v2 | ||
id: base-change | ||
with: | ||
filters: | | ||
src: | ||
- 'dockerfiles/requirements.txt' | ||
- 'dockerfiles/Dockerfile.base' | ||
- '.github/workflows/build-push.yml' | ||
- uses: dorny/paths-filter@v2 | ||
id: metric-change | ||
with: | ||
filters: | | ||
src: | ||
- 'src/util/prom_types.py' | ||
- 'src/util/train_types.py' | ||
- 'src/train/prom/**' | ||
- 'model_training/tekton/tasks/stressng-task.yaml' | ||
- 'model_training/tekton/pipelines/collect.yaml' | ||
- 'hack/**' | ||
- '.github/workflows/collect-data-self-hosted.yml' | ||
- uses: dorny/paths-filter@v2 | ||
id: modeling-change | ||
with: | ||
filters: | | ||
src: | ||
- 'src/**' | ||
- 'model_training/**' | ||
- 'hack/**' | ||
- '.github/workflows/collect-data-self-hosted.yml' | ||
- '.github/workflows/train-model.yml' | ||
unit-test: | ||
needs: [check-change] | ||
uses: ./.github/workflows/unit-test.yml | ||
with: | ||
base_change: ${{ needs.check-change.outputs.base-change }} | ||
|
||
build-push: | ||
needs: [check-change] | ||
uses: ./.github/workflows/build-push.yml | ||
with: | ||
base_change: ${{ needs.check-change.outputs.base-change }} | ||
image_repo: quay.io/sustainable_computing_io | ||
image_tag: pr-${{ github.event.number }} | ||
push: true | ||
secrets: | ||
docker_username: ${{ secrets.BOT_NAME }} | ||
docker_password: ${{ secrets.BOT_TOKEN }} |
Oops, something went wrong.