Release Hotfix image workflow (aigc-apps/PAI-RAG)
The Release Hotfix image workflow from aigc-apps/PAI-RAG, explained and optimized by Latchkey.
CI health: C - fair
Point runs-on at Latchkey and get caching, job timeouts, SHA-pinned actions, self-healing for flaky steps, and up to 58% lower cost, applied automatically.
What it does
This is the Release Hotfix image workflow from the aigc-apps/PAI-RAG repository, a real project running GitHub Actions. It is shown here with attribution under its MIT license.
Below, Latchkey shows a faster, safer version produced by its optimization engine.
The workflow
name: Release Hotfix image
# Configures this workflow to run every time a change is pushed to the branch called `release`.
on:
workflow_dispatch:
inputs:
hotfix_tag:
description: "Hotfix Tag"
required: true
default: ""
# Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds.
env:
REGISTRY: ${{ secrets.BUILD_ACR_URL }}
TEST_REGISTRY: registry.cn-hangzhou.aliyuncs.com
# There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu.
jobs:
build-and-push-image:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Check disk space
run: df . -h
- name: Free disk space
run: |
sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true
sudo rm -rf \
/usr/share/dotnet /usr/local/lib/android /opt/ghc \
/usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \
/usr/lib/jvm || true
df . -h
- name: Extract version
run: |
pip install poetry
VERSION_TAG=$(poetry version --short)
SPECIFIC_VERSION_TAG="$VERSION_TAG-${{ github.event.inputs.hotfix_tag }}"
echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV
echo "SPECIFIC_VERSION_TAG=$SPECIFIC_VERSION_TAG" >> $GITHUB_ENV
echo "version:$SPECIFIC_VERSION_TAG\ncommit_id:$(git rev-parse HEAD)" > __build_version.cfg
CURRENT_TIME="`date +%Y%m%d%H%M%S`"
echo "TIME_VERSION_TAG=$VERSION_TAG-$CURRENT_TIME" >> $GITHUB_ENV
# Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here.
- name: Login to ACR region
uses: docker/login-action@v1
with:
registry: ${{ env.REGISTRY }}
username: ${{ secrets.ACR_USER }}
password: ${{ secrets.ACR_PUBLIC_PASSWORD }}
- name: Login to ACR Hangzhou region
uses: docker/login-action@v1
with:
registry: ${{ env.TEST_REGISTRY }}
username: ${{ secrets.ACR_USER }}
password: ${{ secrets.ACR_PASSWORD }}
- name: Build and push image
env:
IMAGE_TAG: ${{env.VERSION_TAG}}
SPECIFIC_IMAGE_TAG: ${{env.SPECIFIC_VERSION_TAG}}
TEST_IMAGE_TAG: ${{env.TIME_VERSION_TAG}}
run: |
docker build -t ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }} .
docker tag ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }} ${{ env.TEST_REGISTRY }}/mybigpai/pai-rag:$TEST_IMAGE_TAG
docker push ${{ env.TEST_REGISTRY }}/mybigpai/pai-rag:$TEST_IMAGE_TAG
docker push ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }}
- name: Free disk space
run: |
docker image prune --filter "until=168h" --force -aThe same workflow, on Latchkey
Estimated ~20% faster on cache hits, plus fewer wasted runs and a safer supply chain. Added and changed lines are highlighted.
name: Release Hotfix image # Configures this workflow to run every time a change is pushed to the branch called `release`. on: workflow_dispatch: inputs: hotfix_tag: description: "Hotfix Tag" required: true default: "" # Defines two custom environment variables for the workflow. These are used for the Container registry domain, and a name for the Docker image that this workflow builds. env: REGISTRY: ${{ secrets.BUILD_ACR_URL }} TEST_REGISTRY: registry.cn-hangzhou.aliyuncs.com # There is a single job in this workflow. It's configured to run on the latest available version of Ubuntu. jobs: build-and-push-image: timeout-minutes: 30 runs-on: latchkey-small steps: - name: Checkout repository uses: actions/checkout@v4 - uses: actions/setup-python@v4 with: cache: 'pip' python-version: "3.11" - name: Check disk space run: df . -h - name: Free disk space run: | sudo docker rmi $(docker image ls -aq) >/dev/null 2>&1 || true sudo rm -rf \ /usr/share/dotnet /usr/local/lib/android /opt/ghc \ /usr/local/share/powershell /usr/share/swift /usr/local/.ghcup \ /usr/lib/jvm || true df . -h - name: Extract version run: | pip install poetry VERSION_TAG=$(poetry version --short) SPECIFIC_VERSION_TAG="$VERSION_TAG-${{ github.event.inputs.hotfix_tag }}" echo "VERSION_TAG=$VERSION_TAG" >> $GITHUB_ENV echo "SPECIFIC_VERSION_TAG=$SPECIFIC_VERSION_TAG" >> $GITHUB_ENV echo "version:$SPECIFIC_VERSION_TAG\ncommit_id:$(git rev-parse HEAD)" > __build_version.cfg CURRENT_TIME="`date +%Y%m%d%H%M%S`" echo "TIME_VERSION_TAG=$VERSION_TAG-$CURRENT_TIME" >> $GITHUB_ENV # Uses the `docker/login-action` action to log in to the Container registry registry using the account and password that will publish the packages. Once published, the packages are scoped to the account defined here. - name: Login to ACR region uses: docker/login-action@v1 with: registry: ${{ env.REGISTRY }} username: ${{ secrets.ACR_USER }} password: ${{ secrets.ACR_PUBLIC_PASSWORD }} - name: Login to ACR Hangzhou region uses: docker/login-action@v1 with: registry: ${{ env.TEST_REGISTRY }} username: ${{ secrets.ACR_USER }} password: ${{ secrets.ACR_PASSWORD }} - name: Build and push image env: IMAGE_TAG: ${{env.VERSION_TAG}} SPECIFIC_IMAGE_TAG: ${{env.SPECIFIC_VERSION_TAG}} TEST_IMAGE_TAG: ${{env.TIME_VERSION_TAG}} run: | docker build -t ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }} . docker tag ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }} ${{ env.TEST_REGISTRY }}/mybigpai/pai-rag:$TEST_IMAGE_TAG docker push ${{ env.TEST_REGISTRY }}/mybigpai/pai-rag:$TEST_IMAGE_TAG docker push ${{ env.REGISTRY }}/mybigpai/pairag:${{ env.SPECIFIC_IMAGE_TAG }} - name: Free disk space run: | docker image prune --filter "until=168h" --force -a
What changed
- Run on Latchkey managed runners with one line (
runs-on), which apply the fixes below automatically and self-heal transient failures. This example useslatchkey-small; pick the runner size that fits the job. - Cache dependency installs on the setup step so they are served from cache.
- Add a job timeout so a hung step cannot burn hours of runner time.
1 third-party action is referenced by a movable tag. Pin it to the commit SHA (Latchkey resolves and applies this automatically) so a repointed tag cannot change what runs.
What Latchkey heals here
This workflow has steps that commonly fail on transient issues (network, registries, flaky browsers). On Latchkey managed runners they are detected, retried, and self-healed instead of failing your build:
- Dependency installs
- Container pulls and builds
This workflow runs 1 job per trigger. On Latchkey the same minutes cost up to 58% less than GitHub-hosted, with zero queue time.