Fixing the hard way. #19
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: sentence_transformers-docker-cd | |
on: | |
pull_request: | |
push: | |
branches: | |
- main | |
paths: | |
- "docker_images/sentence_transformers/**" | |
jobs: | |
build: | |
runs-on: | |
group: aws-general-8-plus-priv | |
steps: | |
- name: Set up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: "3.10" | |
- name: Checkout | |
uses: actions/checkout@v4 | |
- name: Initialize Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
with: | |
install: true | |
buildkitd-config: /tmp/buildkitd.toml | |
- name: Inject slug/short variables | |
uses: rlespinasse/[email protected] | |
- name: Login to internal Container Registry | |
uses: docker/login-action@v3 | |
with: | |
username: ${{ secrets.REGISTRY_USERNAME }} | |
password: ${{ secrets.REGISTRY_PASSWORD }} | |
registry: registry.internal.huggingface.tech | |
- name: Extract metadata (tags, labels) for Docker | |
id: meta-pr | |
uses: docker/metadata-action@v5 | |
with: | |
images: | | |
registry.internal.huggingface.tech/api-inference/community | |
tags: | | |
type=raw,value=sha-${{ env.GITHUB_SHA_SHORT }} | |
- name: Build and push Docker image | |
id: build-and-push | |
uses: docker/build-push-action@v4 | |
with: | |
context: docker_images/sentence_transformers | |
dockerfile: docker_images/sentence_transformers/Dockerfile | |
push: true | |
platforms: 'linux/amd64' | |
build-args: | | |
GIT_SHA=${{ env.GITHUB_SHA }} | |
DOCKER_LABEL=sentence-transformers-sha-${{ env.GITHUB_SHA_SHORT }} | |
PLATFORM=${{ env.PLATFORM }} | |
tags: ${{ steps.meta.outputs.tags || steps.meta-pr.outputs.tags }} | |
labels: ${{ steps.meta.outputs.labels || steps.meta-pr.outputs.labels }} | |
cache-from: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=sentence-transformers-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min | |
cache-to: type=s3,region=us-east-1,bucket=ci-docker-buildx-cache,name=sentence-transformers-cache${{ env.LABEL }},mode=min,access_key_id=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_ACCESS_KEY_ID }},secret_access_key=${{ secrets.S3_CI_DOCKER_BUILDX_CACHE_SECRET_ACCESS_KEY }},mode=min | |
- name: Deploy on API | |
run: | | |
# Load the tags into the env | |
echo sha-${{ env.GITHUB_SHA_SHORT }} | |
# Weird single quote escape mechanism because string interpolation does | |
# not work on single quote in bash | |
curl -H "Authorization: Bearer ${{ secrets.API_GITHUB_TOKEN }}" https://api.github.com/repos/huggingface-internal/api-inference/actions/workflows/update_community.yaml/dispatches -d '{"ref":"main","inputs":{"framework":"SENTENCE_TRANSFORMERS","tag": "sentence-transformers-sha-${{ env.GITHUB_SHA_SHORT }}"}}' | |