Skip to content

Commit

Permalink
ci: add image build workflow
Browse files Browse the repository at this point in the history
Signed-off-by: richardli1598 <richardli1598@gmail.com>
  • Loading branch information
richardli1598 committed Oct 8, 2023
1 parent 2a9a6f7 commit 48ecf34
Show file tree
Hide file tree
Showing 9 changed files with 74 additions and 1 deletion.
30 changes: 30 additions & 0 deletions .github/workflows/steps-image-build.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
# Copyright 2023 opennaslab
# SPDX-License-Identifier: Apache-2.0

name: Build bifrost steps image
on:
workflow_dispatch: {}

jobs:
build:
runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v3

- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v39

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.ORG_DOCKERHUB_USER }}
password: ${{ secrets.ORG_DOCKERHUB_PASSWORD }}

- name: List all changed files
run: |
cache_file=$(mktemp)
for file in ${{ steps.changed-files.outputs.all_changed_files }}; do
step_path=$(hack/build-step.sh ${file} ${cache_file})
done
41 changes: 41 additions & 0 deletions hack/build-step.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
#!/bin/env bash

set -o errexit

function usage() {
echo "This script is used to parse step."
echo "Usage: hack/build-step.sh $file $cache_file"
echo "Example: hack/build-step.sh steps/frpc-config/Dockerfile /tmp/step-cache"
}

if [[ $# -ne 2 ]]; then
usage
exit 1
fi

change_file_path=$1
cache_file=$2

function parse_step_name() {
file_path=$1
if [[ "$file_path" =~ ^steps* ]]; then
step_name=$(echo $1 | cut -d '/' -f 2)
echo "$step_name"
else
echo ""
fi
}

step_name=$(parse_step_name $change_file_path)
if [ -z "$step_name" ]; then
exit 0
fi
build_step=$(cat $cache_file)
if [[ "$build_step" =~ "$step_name" ]]; then
exit 0
fi

echo "$step_name" >> $cache_file

docker build -t opennaslab/$step_name:latest steps/$step_name
docker push opennaslab/$step_name:latest
Empty file removed local-step/frpc-config/Dockerfile
Empty file.
Empty file removed remote-step/frps-config/Dockerfile
Empty file.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM opennaslab/bifrosr-base:latest
FROM opennaslab/bifrost-registry-base:latest

WORKDIR /root

Expand Down
File renamed without changes.
1 change: 1 addition & 0 deletions steps/frpc-config/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM opennaslab/bifrost-registry-base:latest
1 change: 1 addition & 0 deletions steps/frps-config/Dockerfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
FROM opennaslab/bifrost-registry-base:latest

0 comments on commit 48ecf34

Please sign in to comment.