Skip to content

Update acr_sync.yml #16

Update acr_sync.yml

Update acr_sync.yml #16

Workflow file for this run

name: Sync Docker Images to Alibaba Cloud from Docker Compose
on:
push:
branches:
- main
jobs:
sync-images:
runs-on: ubuntu-latest
steps:
- name: Checkout code from Dify repo
uses: actions/checkout@v3
with:
repository: langgenius/dify # 拉取 langgenius/dify 仓库
path: dify-repo # 将该 repo 克隆到 dify-repo 目录中
- name: Install yq
run: |
sudo wget https://github.com/mikefarah/yq/releases/download/v4.27.3/yq_linux_amd64 -O /usr/bin/yq
sudo chmod +x /usr/bin/yq
- name: Parse docker-compose.yaml for images
id: parse_docker_compose
run: |
images=$(yq e '.services[].image // ""' dify-repo/docker/docker-compose.yaml | grep -v '^$' | tr '\n' ' ')
echo "Images: $images"
echo "::set-output name=images::$images"
- name: Log in to Alibaba Cloud ACR
run: echo "${{ secrets.ACR_PASSWORD }}" | docker login ${{ secrets.ACR_REGISTRY }} --username ${{ secrets.ACR_USERNAME }} --password-stdin
- name: Pull and push images to Alibaba Cloud ACR
run: |
images="${{ steps.parse_docker_compose.outputs.images }}"
for image in $images; do
echo "Processing image: $image"
# Pull the image from DockerHub
docker pull $image
# Extract image tag (last part)
image_tag=$(echo $image | awk -F'/' '{print $NF}')
# Tag the image for ACR
acr_image="${{ secrets.ACR_REGISTRY }}/kenwood-ai/$image_tag"
echo "Tagging image: $acr_image"
docker tag $image $acr_image
docker rmi $image
# Push the image to ACR
echo "Pushing image to ACR: $acr_image"
docker push $acr_image
docker rmi $acr_image
done