-
Notifications
You must be signed in to change notification settings - Fork 0
Publish AI Toolkit worker image automatically #3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,7 @@ | ||
| .git | ||
| .github | ||
| __pycache__ | ||
| *.pyc | ||
| *.py[cod] | ||
| .pytest_cache | ||
| .venv | ||
| venv |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| name: Build and publish worker image | ||
|
|
||
| on: | ||
| push: | ||
| branches: | ||
| - main | ||
| pull_request: | ||
| workflow_dispatch: | ||
|
|
||
| permissions: | ||
| contents: read | ||
|
|
||
| concurrency: | ||
| group: worker-image-${{ github.ref }} | ||
| cancel-in-progress: true | ||
|
|
||
| env: | ||
| IMAGE_NAME: docker.io/kalebbroo/runpod-serverless-aitoolkit | ||
|
|
||
| jobs: | ||
| test: | ||
| name: Test worker | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Python | ||
| uses: actions/setup-python@v6 | ||
| with: | ||
| python-version: "3.12" | ||
| cache: pip | ||
|
|
||
| - name: Install worker dependencies | ||
| run: python -m pip install --requirement requirements.txt | ||
|
|
||
| - name: Run worker tests | ||
| run: | | ||
| python -m unittest discover -s tests -v | ||
| python -m py_compile handler.py tests/test_handler.py | ||
|
|
||
| image: | ||
| name: Build worker image | ||
| needs: test | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Check out repository | ||
| uses: actions/checkout@v5 | ||
|
|
||
| - name: Set up Docker Buildx | ||
| uses: docker/setup-buildx-action@v4 | ||
|
|
||
| - name: Sign in to Docker Hub | ||
| if: github.event_name != 'pull_request' | ||
| uses: docker/login-action@v4 | ||
| with: | ||
| username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
| password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
|
|
||
| - name: Generate image metadata | ||
| id: metadata | ||
| uses: docker/metadata-action@v6 | ||
| with: | ||
| images: ${{ env.IMAGE_NAME }} | ||
| tags: | | ||
| type=sha,format=long,prefix=sha- | ||
| type=raw,value=latest,enable=${{ github.ref == 'refs/heads/main' }} | ||
|
|
||
| - name: Build and publish worker image | ||
| uses: docker/build-push-action@v7 | ||
| with: | ||
| context: . | ||
| file: ./Dockerfile | ||
| platforms: linux/amd64 | ||
| push: ${{ github.event_name != 'pull_request' }} | ||
| tags: ${{ steps.metadata.outputs.tags }} | ||
| labels: ${{ steps.metadata.outputs.labels }} | ||
| cache-from: type=gha | ||
| cache-to: type=gha,mode=max | ||
| provenance: ${{ github.event_name != 'pull_request' && 'mode=max' || 'false' }} | ||
| sbom: ${{ github.event_name != 'pull_request' }} | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,24 @@ docker build --pull --build-arg AI_TOOLKIT_REVISION=be995185f598c83abb990a088e9f | |
| docker push your-registry/hartsy-ai-toolkit:be995185 | ||
| ``` | ||
|
|
||
| ## Automatic Docker Hub publishing | ||
|
|
||
| The `Build and publish worker image` GitHub Actions workflow tests and builds every pull request. A push to `main`, or a manual workflow dispatch, publishes the Linux AMD64 image to: | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win 🔎 Supported by static analysis🏁 Script executed: printf '%s\n' '--- README context ---'
sed -n '1,28p' README.md
printf '%s\n' '--- workflow files ---'
git ls-files | grep -E '(^|/)\.github/workflows/.*\.(yml|yaml)$'
printf '%s\n' '--- publish workflow references ---'
rg -n -C 8 'Build and publish worker image|github\.ref|latest|workflow_dispatch|tags:' .github/workflowsRepository: HartsyAI/Runpod-Serverless-AIToolkit Length of output: 6675 🌐 Web query:
💡 Result: To manually trigger a GitHub Actions workflow using the workflow_dispatch event, you can specify a branch or tag using the following methods [1][2]. When you trigger a workflow, the GITHUB_REF environment variable is set to the branch or tag you selected [3]. Methods to choose a branch or tag: 1. GitHub UI: - Navigate to the Actions tab in your repository [1]. - Select the desired workflow in the left sidebar [1]. - Click the "Run workflow" button [1]. - Use the "Branch" dropdown menu to select the branch or tag you wish to run the workflow on [1][2]. 2. GitHub CLI (gh): - Use the gh workflow run command with the --ref flag [4][1]. - Example: gh workflow run --ref [1][2]. 3. REST API: - When calling the workflow dispatch endpoint, include the ref parameter in the request body [1][2]. Requirements: - The workflow file must contain the on: workflow_dispatch trigger [3][1]. - The workflow file must exist on the repository's default branch for the trigger to be available, even if you intend to run it against a different branch or tag [3][1]. Citations:
Correct the manual-dispatch tag description. Because 🤖 Prompt for AI AgentsSource: MCP tools |
||
|
|
||
| ```text | ||
| docker.io/kalebbroo/runpod-serverless-aitoolkit:latest | ||
| docker.io/kalebbroo/runpod-serverless-aitoolkit:sha-<full-git-commit> | ||
| ``` | ||
|
|
||
| Configure these GitHub Actions repository secrets before merging the workflow: | ||
|
|
||
| - `DOCKERHUB_USERNAME`: `kalebbroo` | ||
| - `DOCKERHUB_TOKEN`: a Docker Hub personal access token with Read & Write permission | ||
|
|
||
| Create the `kalebbroo/runpod-serverless-aitoolkit` Docker Hub repository first. Do not store a Docker Hub password or token in the repository. Use the immutable `sha-<full-git-commit>` tag in the RunPod template; `latest` is a convenience tag for inspection and manual testing. | ||
|
|
||
| The workflow publishes BuildKit provenance and an SBOM with release images and uses the GitHub Actions cache for subsequent builds. | ||
|
|
||
| Create a queue-based RunPod Serverless endpoint from that immutable image. Use one concurrent request per worker because `/dataset` and `/workspace/output` are intentionally reset for every request. Allocate enough container disk for the model cache plus dataset/output and choose a GPU configuration appropriate for the largest model families you enable. Hartsy sends a 24-hour execution policy and seven-day status TTL by default; the endpoint must permit those limits. | ||
|
|
||
| Required worker environment: | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
Repository: HartsyAI/Runpod-Serverless-AIToolkit
Length of output: 3539
Security Misconfiguration (CWE-829): Inclusion of Functionality from Untrusted Control Sphere
Reachability: External · Exploitability: Difficult
Pin release actions to full commit SHAs.
These workflow steps use mutable major-version tags. Replace each
@vNreference with a verified full commit SHA and retain the release version in a comment.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 25-26: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Source: MCP tools
🔒 Security & Privacy | 🟡 Minor | ⚡ Quick win
🧩 Analysis chain
🏁 Script executed:
sed -n '1,90p' .github/workflows/publish-image.ymlRepository: HartsyAI/Runpod-Serverless-AIToolkit
Length of output: 2365
Sensitive Data Exposure (CWE-522): Insufficiently Protected Credentials
Reachability: External · Exploitability: Trivial
Disable checkout credential persistence in both jobs.
Set
persist-credentials: falseon bothactions/checkoutsteps. Pull-request steps execute repository-controlled code, which can read the persisted checkout token from local Git configuration.🧰 Tools
🪛 zizmor (1.29.0)
[warning] 25-26: credential persistence through GitHub Actions artifacts (artipacked): does not set persist-credentials: false
(artipacked)
🤖 Prompt for AI Agents
Sources: MCP tools, Linters/SAST tools