Skip to content

Commit 40a21b7

Browse files
authored
Refactor diffusers CD (#442)
* Refactor diffusers CD - Do not push to internal registry anymore (no access), use ghcr instead - Do not use tailscale (no need, if we do not push to internal registry) - Remove autosync -> not working, will be refactored - TODO: adapt other frameworks as well
1 parent bf9c58e commit 40a21b7

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

.github/workflows/python-api-diffusers-cd.yaml

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -4,45 +4,45 @@ on:
44
branches:
55
- main
66
paths:
7+
- ".github/workflows/python-api-diffusers-cd.yaml"
78
- "docker_images/diffusers/**"
9+
concurrency:
10+
group: diffusers-cd-${{ github.head_ref }}
11+
cancel-in-progress: true
812
jobs:
913
build:
1014
runs-on: ubuntu-latest
15+
permissions:
16+
packages: write
17+
contents: read
1118
steps:
12-
- name: Set up Python ${{ matrix.python-version }}
13-
uses: actions/setup-python@v2
14-
with:
15-
python-version: "3.8"
1619
- name: Checkout
17-
uses: actions/checkout@v2
18-
- name: Set up QEMU
19-
uses: docker/setup-qemu-action@v1
20+
uses: actions/checkout@v4.1.7
21+
- name: Inject slug/short variables
22+
uses: rlespinasse/github-slug-action@v4.5.0
2023
- name: Set up Docker Buildx
21-
uses: docker/setup-buildx-action@v1
22-
- name: Install dependencies
24+
uses: docker/setup-buildx-action@v3.6.1
25+
- name: downcase REPO
2326
run: |
24-
pip install --upgrade pip
25-
pip install awscli
26-
- uses: tailscale/github-action@v1
27+
echo "CONTAINER_REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
28+
- name: Docker meta
29+
id: meta
30+
uses: docker/[email protected]
2731
with:
28-
authkey: ${{ secrets.TAILSCALE_AUTHKEY }}
29-
- name: Update upstream
30-
env:
31-
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}
32-
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
33-
AWS_DEFAULT_REGION: ${{ secrets.AWS_DEFAULT_REGION }}
34-
DEFAULT_HOSTNAME: ${{ secrets.DEFAULT_HOSTNAME }}
35-
REGISTRY_USERNAME: ${{ secrets.REGISTRY_USERNAME }}
36-
REGISTRY_PASSWORD: ${{ secrets.REGISTRY_PASSWORD }}
37-
run: |
38-
python build_docker.py diffusers --out out.txt
39-
- name: Deploy on API (CPU + GPU)
40-
run: |
41-
# Load the tags into the env
42-
cat out.txt >> $GITHUB_ENV
43-
export $(xargs < out.txt)
44-
echo ${DIFFUSERS_CPU_TAG}
45-
# Weird single quote escape mechanism because string interpolation does
46-
# not work on single quote in bash
47-
curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"framework":"DIFFUSERS","tag": "'"${DIFFUSERS_CPU_TAG}"'"}}'
48-
curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"compute": "GPU", "framework":"DIFFUSERS","tag": "'"${DIFFUSERS_CPU_TAG}"'"}}'
32+
images: ghcr.io/${{ env.CONTAINER_REPO }}
33+
- name: Login to GitHub Container Registry
34+
uses: docker/[email protected]
35+
with:
36+
registry: ghcr.io
37+
username: ${{ github.actor }}
38+
password: ${{ secrets.GITHUB_TOKEN }}
39+
- name: Build and push Docker image
40+
id: build-and-push
41+
uses: docker/[email protected]
42+
with:
43+
context: docker_images/diffusers
44+
push: true
45+
platforms: 'linux/amd64'
46+
tags: ghcr.io/${{ env.CONTAINER_REPO }}/diffusers:${{ env.GITHUB_SHA_SHORT || steps.meta-pr.outputs.tags }}
47+
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }}
48+
# TODO: cache-from/cache-to

0 commit comments

Comments
 (0)