-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
112 additions
and
80 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
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,91 @@ | ||
on: | ||
workflow_call: | ||
inputs: | ||
platform: | ||
required: true | ||
type: string | ||
builder: | ||
required: true | ||
type: string | ||
registry: | ||
required: true | ||
type: string | ||
tag_prefix: | ||
required: false | ||
type: string | ||
context: | ||
required: false | ||
type: string | ||
jobs: | ||
build: | ||
runs-on: ${{ inputs.builder }} | ||
permissions: | ||
contents: read | ||
packages: write | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- name: Login to ghcr.io | ||
uses: docker/#-action@v3 | ||
with: | ||
registry: ghcr.io | ||
username: ${{github.actor}} | ||
password: ${{secrets.GITHUB_TOKEN}} | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v3 | ||
- name: Set image tag | ||
run: | | ||
short_sha=$(git rev-parse --short ${{ github.sha }}) | ||
echo "TAG=${{ inputs.registry }}:${{ inputs.tag_prefix }}${short_sha}" >> "$GITHUB_ENV" | ||
- name: Build Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
platforms: linux/${{ inputs.platform }} | ||
context: ${{ inputs.context || '.' }} | ||
push: false | ||
tags: ${{ env.TAG }} | ||
cache-from: type=gha,scope=computer-use-${{ inputs.platform }} | ||
cache-to: type=gha,mode=max,scope=computer-use-${{ inputs.platform }} | ||
load: true | ||
- name: Run container | ||
run: docker run -d -p 8051:8051 ${{ env.TAG }} | ||
- name: Check streamlit | ||
run: | | ||
timeout=60 | ||
start_time=$(date +%s) | ||
docker_id=$(docker ps --filter "ancestor=${{ env.TAG }}" --format "{{.ID}}") | ||
echo "docker_id=$docker_id" >> "$GITHUB_ENV" | ||
while true; do | ||
current_time=$(date +%s) | ||
elapsed=$((current_time - start_time)) | ||
if [ $elapsed -ge $timeout ]; then | ||
echo "Timeout reached. Container did not respond within $timeout seconds." | ||
exit 1 | ||
fi | ||
response=$(docker exec $docker_id curl -s -o /dev/null -w "%{http_code}" http://127.0.0.1:8501 || echo "000") | ||
if [ "$response" = "200" ]; then | ||
echo "Container responded with 200 OK" | ||
exit 0 | ||
fi | ||
done | ||
- name: Check VNC | ||
run: docker exec $docker_id nc localhost 5900 -z | ||
- name: Check noVNC | ||
run: docker exec $docker_id curl -s -o /dev/null -w "%{http_code}" http://localhost:6080 | grep -q 200 || exit 1 | ||
- name: Check landing page | ||
run: docker exec $docker_id curl -s -o /dev/null -w "%{http_code}" http://localhost:8080 | grep -q 200 || exit 1 | ||
- name: Determine push tags | ||
run: | | ||
if [ "${{ github.event_name }}" == "pull_request" ]; then | ||
echo "PUSH_TAGS=${TAG}-${{ inputs.platform }}" >> "$GITHUB_ENV" | ||
else | ||
echo "PUSH_TAGS=${TAG}-${{ inputs.platform }},${{ inputs.registry }}:${{ inputs.tag_prefix }}latest-${{ inputs.platform }}" >> "$GITHUB_ENV" | ||
fi | ||
- name: Push Docker image | ||
uses: docker/build-push-action@v5 | ||
with: | ||
platforms: linux/${{ inputs.platform }} | ||
context: ${{ inputs.context || '.' }} | ||
push: true | ||
tags: ${{ env.PUSH_TAGS }} | ||
cache-from: type=gha,scope=computer-use-${{ inputs.platform }} | ||
cache-to: type=gha,mode=max,scope=computer-use-${{ inputs.platform }} |