feat: add GitHub Actions workflow for deploying to GitHub Pages #30
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
name: Create and publish a Docker image | ||
on: | ||
push: | ||
branches: | ||
- "main" | ||
- "test" | ||
jobs: | ||
docker-build: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
include: | ||
- cuda_version: 12.1.0 | ||
pytorch_version: 2.3.1 | ||
- cuda_version: 12.4.0 | ||
pytorch_version: 2.4 | ||
env: | ||
IMAGE_NAME: ${{ github.repository }} | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: Adjutment docker volumes | ||
run: | | ||
docker system df | ||
docker system prune -a --volumes -f | ||
docker system df | ||
df | ||
- name: Set up Docker Buildx | ||
uses: docker/setup-buildx-action@v1 | ||
- name: Login to Docker Hub | ||
uses: docker/login-action@v2 | ||
with: | ||
username: ${{ secrets.DOCKERHUB_USERNAME }} | ||
password: ${{ secrets.DOCKERHUB_TOKEN }} | ||
- name: Set short SHA | ||
run: echo "SHORT_SHA=${GITHUB_SHA::6}" >> $GITHUB_ENV | ||
- name: Build and push | ||
uses: docker/build-push-action@v4 | ||
with: | ||
context: . | ||
push: true | ||
build-args: | | ||
CUDA_VERSION=${{ matrix.cuda_version }} | ||
PYTORCH_VERSION=${{ matrix.pytorch_version }} | ||
tags: | | ||
${{ github.repository }}:${{ matrix.cuda_version }}-${{ env.SHORT_SHA }} | ||
${{ github.repository }}:${{ matrix.cuda_version }} | ||
cache-from: type=registry,ref=${{ github.repository }}:cache-${{ matrix.cuda_version }} | ||
cache-to: type=registry,ref=${{ github.repository }}:cache-${{ matrix.cuda_version }},mode=max | ||
generate-redoc: | ||
runs-on: ubuntu-latest | ||
needs: docker-build # このジョブはdocker-buildが完了した後に実行されます | ||
steps: | ||
- name: checkout | ||
uses: actions/checkout@v2 | ||
- name: Run Docker container | ||
run: | | ||
docker run -d -p 7680:7680 --name sd-forge-container -e ARGS="--listen --enable-insecure-extension-access --port 7680 --nowebui --api --always-cpu --skip-torch-cuda-test --skip-install" sammrai/sd-forge-docker:latest | ||
sleep 30 # Adjust if necessary, based on how long it takes the app to initialize | ||
- name: Download openapi.json | ||
run: | | ||
curl -o openapi.json http://localhost:7680/openapi.json | ||
- name: Install Redoc CLI | ||
run: | | ||
npm install -g redoc-cli | ||
- name: Generate Redoc HTML | ||
run: | | ||
redoc-cli bundle openapi.json --output openapi.html | ||
- name: Upload Redoc HTML as an artifact | ||
uses: actions/upload-artifact@v3 | ||
with: | ||
name: openapi-redoc | ||
path: openapi.html | ||
- name: Clean up Docker container | ||
run: | | ||
docker stop sd-forge-container | ||
docker rm sd-forge-container | ||
- uses: actions/upload-pages-artifact@v1 | ||
with: | ||
path: pages | ||
deploy: | ||
needs: build | ||
Check failure on line 97 in .github/workflows/build-docker-image.yml
|
||
runs-on: ubuntu-latest | ||
timeout-minutes: 5 | ||
environment: | ||
name: github-pages | ||
url: ${{ steps.deployment.outputs.page_url }} | ||
permissions: | ||
pages: write | ||
id-token: write | ||
steps: | ||
- uses: actions/deploy-pages@v1 | ||
id: deployment |