-
-
Notifications
You must be signed in to change notification settings - Fork 4
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
1 parent
55f1786
commit 6faaacf
Showing
47 changed files
with
1,130 additions
and
0 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 |
---|---|---|
@@ -0,0 +1,3 @@ | ||
# These are supported funding model platforms | ||
|
||
github: [ai-dock, robballantyne] |
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,55 @@ | ||
# https://stackoverflow.com/a/73556714 | ||
name: Clear Cache | ||
|
||
on: | ||
workflow_dispatch: | ||
|
||
permissions: | ||
actions: write | ||
|
||
jobs: | ||
clear-cache: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Clear cache | ||
uses: actions/github-script@v6 | ||
with: | ||
script: | | ||
console.log("About to clear") | ||
const response = await github.rest.actions.getActionsCacheList({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
page: 1, | ||
per_page: 100 | ||
}); | ||
const pages = (function() { | ||
if (typeof response.headers.link !== 'undefined') { | ||
return response.headers.link.split(">").slice(-2)[0].split('=').slice(-1)[0] | ||
} | ||
return 1; | ||
})(); | ||
console.log("Total pages: " + pages); | ||
for (let page = pages; page >= 1; page--) { | ||
console.log("Processing page " + page) | ||
const response = await github.rest.actions.getActionsCacheList({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
page: page, | ||
per_page: 100 | ||
}); | ||
for (const cache of response.data.actions_caches) { | ||
console.log(cache) | ||
github.rest.actions.deleteActionsCacheById({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
cache_id: cache.id, | ||
}) | ||
} | ||
} | ||
console.log("Clear completed") |
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,110 @@ | ||
name: Delete Old Packages | ||
|
||
env: | ||
PER_PAGE: 100 | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
age: | ||
type: choice | ||
required: true | ||
description: Delete older than | ||
options: | ||
- 1 Hour | ||
- 12 Hours | ||
- 1 Day | ||
- 1 Week | ||
- 2 Weeks | ||
- 1 Month | ||
- 6 Months | ||
- 1 Year | ||
- 2 Years | ||
- 3 Years | ||
- 4 Years | ||
- 5 Years | ||
- All Packages | ||
|
||
jobs: | ||
delete-old-packages: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
run: | | ||
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | ||
echo "OWNER=orgs/${GITHUB_REPOSITORY_OWNER,,}" >> ${GITHUB_ENV} | ||
- | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }} | ||
script: | | ||
const delete_age = (function() { | ||
switch ("${{ github.event.inputs.age }}") { | ||
case "All Packages": | ||
return 0; | ||
case "1 Hour": | ||
return 60; | ||
case "12 Hours": | ||
return 720; | ||
case "1 Day": | ||
return 1440; | ||
case "1 Week": | ||
return 10080; | ||
case "2 Weeks": | ||
return 20160; | ||
case "1 Month": | ||
return 43800; | ||
case "6 Months": | ||
return 262800; | ||
case "1 Year": | ||
return 525600; | ||
case "2 Years": | ||
return 525600 * 2; | ||
case "3 Years": | ||
return 525600 * 3; | ||
case "4 Years": | ||
return 525600 * 4; | ||
case "5 Years": | ||
return 525600 * 5; | ||
default: | ||
return 157680000; | ||
} | ||
})(); | ||
const now = new Date(); | ||
const epoch_minutes = Math.round(now.getTime() / 1000 / 60); | ||
const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions", | ||
{ per_page: ${{ env.PER_PAGE }} | ||
}); | ||
const pages = (function() { | ||
if (typeof response.headers.link !== 'undefined') { | ||
return response.headers.link.split(">").slice(-2)[0].split('=').slice(-1)[0] | ||
} | ||
return 1; | ||
})(); | ||
console.log("Total pages: " + pages); | ||
for (let page = pages; page >= 1; page--) { | ||
console.log("Processing page " + page) | ||
const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions", | ||
{ | ||
per_page: ${{ env.PER_PAGE }}, | ||
page: page | ||
}); | ||
console.log("Deleting packages updated more than " + delete_age + " minutes ago...") | ||
for (version of response.data) { | ||
let updated_at = new Date(version.updated_at) | ||
let minutes_old = epoch_minutes - Math.round(updated_at.getTime() / 1000 / 60); | ||
console.log("Package is " + minutes_old + " minutes old") | ||
if (minutes_old > delete_age) { | ||
console.log("delete " + version.id) | ||
const deleteResponse = await github.request("DELETE /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions/" + version.id, { }); | ||
console.log("status " + deleteResponse.status) | ||
} | ||
} | ||
} |
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,56 @@ | ||
name: Delete Untagged Packages | ||
|
||
env: | ||
PER_PAGE: 100 | ||
|
||
on: | ||
workflow_dispatch: | ||
workflow_run: | ||
workflows: ["Docker Build"] | ||
types: | ||
- completed | ||
|
||
jobs: | ||
delete-untagged: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- | ||
run: | | ||
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | ||
echo "OWNER=orgs/${GITHUB_REPOSITORY_OWNER,,}" >> ${GITHUB_ENV} | ||
- | ||
uses: actions/github-script@v6 | ||
with: | ||
github-token: ${{ secrets.DELETE_PACKAGES_TOKEN }} | ||
script: | | ||
const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions", | ||
{ per_page: ${{ env.PER_PAGE }} | ||
}); | ||
const pages = (function() { | ||
if (typeof response.headers.link !== 'undefined') { | ||
return response.headers.link.split(">").slice(-2)[0].split('=').slice(-1)[0] | ||
} | ||
return 1; | ||
})(); | ||
console.log("Total pages: " + pages); | ||
for (let page = pages; page >= 1; page--) { | ||
console.log("Processing page " + page) | ||
const response = await github.request("GET /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions", | ||
{ | ||
per_page: ${{ env.PER_PAGE }}, | ||
page: page | ||
}); | ||
for (version of response.data) { | ||
if (version.metadata.container.tags.length == 0) { | ||
console.log("delete " + version.id) | ||
const deleteResponse = await github.request("DELETE /${{ env.OWNER }}/packages/container/${{ github.event.repository.name }}/versions/" + version.id, { }); | ||
console.log("status " + deleteResponse.status) | ||
} | ||
} | ||
} | ||
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,163 @@ | ||
name: Docker Build | ||
|
||
on: | ||
workflow_dispatch: | ||
#push: | ||
# branches: [ "main" ] | ||
|
||
env: | ||
UBUNTU_VERSION: 22.04 | ||
BUILDX_NO_DEFAULT_ATTESTATIONS: 1 | ||
|
||
jobs: | ||
nvidia-base: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: | ||
# Undeclared release tag finds latest from GitHub tags | ||
- {latest: "true", tag: "v24.1.4", python: "3.10", pytorch: "2.2.2", cuda: "12.1.0-runtime"} | ||
|
||
steps: | ||
- | ||
name: Free Space | ||
run: | | ||
df -h | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf /usr/local/.ghcup | ||
sudo rm -rf /usr/local/share/boost | ||
sudo rm -rf /usr/local/lib/android | ||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
df -h | ||
- | ||
name: Env Setter | ||
run: | | ||
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Permissions fixes | ||
run: | | ||
reponame="$(basename ${GITHUB_REPOSITORY})" | ||
target="${HOME}/work/${reponame}/${reponame}/build/COPY*" | ||
chmod -R ug+rwX ${target} | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Set tags | ||
run: | | ||
img_path="ghcr.io/${{ env.PACKAGE_NAME }}" | ||
if [[ -z '${{ matrix.build.tag }}' ]]; then | ||
KOHYA_TAG="$(curl -s https://api.github.com/repos/bmaltais/kohya_ss/tags | jq -r '.[0].name')" | ||
else | ||
KOHYA_TAG="${{ matrix.build.tag }}" | ||
fi | ||
[ -z "$KOHYA_TAG" ] && { echo "Error: KOHYA_TAG is empty. Exiting script." >&2; exit 1; } | ||
echo "KOHYA_TAG=${KOHYA_TAG}" >> ${GITHUB_ENV} | ||
base_tag="cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }}" | ||
if [[ ${{ matrix.build.latest }} == "true" ]]; then | ||
echo "Marking latest" | ||
TAGS="${img_path}:${base_tag}, ${img_path}:latest, ${img_path}:latest-cuda" | ||
else | ||
TAGS="${img_path}:${base_tag}-${KOHYA_TAG}" | ||
fi | ||
echo "TAGS=${TAGS}" >> ${GITHUB_ENV} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: build | ||
build-args: | | ||
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-cuda-${{ matrix.build.cuda }}-${{ env.UBUNTU_VERSION }} | ||
PYTHON_VERSION=${{ matrix.build.python }} | ||
PYTORCH_VERSION=${{ matrix.build.pytorch }} | ||
KOHYA_TAG=${{ env.KOHYA_TAG }} | ||
push: true | ||
provenance: false | ||
tags: ${{ env.TAGS }} | ||
|
||
amd-base: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
build: | ||
- {latest: "true", tag: "v24.1.4", python: "3.10", pytorch: "2.2.2", rocm: "5.7-runtime"} | ||
steps: | ||
- | ||
name: Free Space | ||
run: | | ||
df -h | ||
sudo rm -rf /usr/share/dotnet | ||
sudo rm -rf /opt/ghc | ||
sudo rm -rf /usr/local/.ghcup | ||
sudo rm -rf /usr/local/share/boost | ||
sudo rm -rf /usr/local/lib/android | ||
sudo rm -rf "$AGENT_TOOLSDIRECTORY" | ||
df -h | ||
- | ||
name: Env Setter | ||
run: | | ||
echo "PACKAGE_NAME=${GITHUB_REPOSITORY,,}" >> ${GITHUB_ENV} | ||
- | ||
name: Checkout | ||
uses: actions/checkout@v3 | ||
- | ||
name: Permissions fixes | ||
run: | | ||
reponame="$(basename ${GITHUB_REPOSITORY})" | ||
target="${HOME}/work/${reponame}/${reponame}/build/COPY*" | ||
chmod -R ug+rwX ${target} | ||
- | ||
name: Login to GitHub Container Registry | ||
uses: docker/login-action@v2 | ||
with: | ||
registry: ghcr.io | ||
username: ${{ github.actor }} | ||
password: ${{ secrets.GITHUB_TOKEN }} | ||
- | ||
name: Set tags | ||
run: | | ||
img_path="ghcr.io/${{ env.PACKAGE_NAME }}" | ||
if [[ -z '${{ matrix.build.tag }}' ]]; then | ||
KOHYA_TAG="$(curl -s https://api.github.com/repos/bmaltais/kohya_ss/tags | jq -r '.[0].name')" | ||
else | ||
KOHYA_TAG="${{ matrix.build.tag }}" | ||
fi | ||
[ -z "$KOHYA_TAG" ] && { echo "Error: KOHYA_TAG is empty. Exiting script." >&2; exit 1; } | ||
echo "KOHYA_TAG=${KOHYA_TAG}" >> ${GITHUB_ENV} | ||
base_tag="rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }}" | ||
if [[ ${{ matrix.build.latest }} == "true" ]]; then | ||
echo "Marking latest" | ||
TAGS="${img_path}:${base_tag}, ${img_path}:latest-rocm" | ||
else | ||
TAGS="${img_path}:${base_tag}-${KOHYA_TAG}" | ||
fi | ||
echo "TAGS=${TAGS}" >> ${GITHUB_ENV} | ||
- | ||
name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: build | ||
build-args: | | ||
IMAGE_BASE=ghcr.io/ai-dock/python:${{ matrix.build.python }}-rocm-${{ matrix.build.rocm }}-${{ env.UBUNTU_VERSION }} | ||
PYTHON_VERSION=${{ matrix.build.python }} | ||
PYTORCH_VERSION=${{ matrix.build.pytorch }} | ||
KOHYA_TAG=${{ env.KOHYA_TAG }} | ||
push: true | ||
provenance: false | ||
tags: ${{ env.TAGS }} |
Oops, something went wrong.