Skip to content

Commit

Permalink
Create acr_sync.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
kenwoodjw authored Sep 13, 2024
1 parent ff20c4b commit f82cd91
Showing 1 changed file with 43 additions and 0 deletions.
43 changes: 43 additions & 0 deletions .github/workflows/acr_sync.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
name: Sync Docker Images to Alibaba Cloud

on:
push:
branches:
- main

jobs:
sync-images:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v3

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Log in to DockerHub
run: echo "${{ secrets.DOCKERHUB_TOKEN }}" | docker login --username ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin

- name: Log in to Alibaba Cloud ACR
run: echo "${{ secrets.ACR_PASSWORD }}" | docker login ${{ secrets.ACR_REGISTRY }} --username ${{ secrets.ACR_USERNAME }} --password-stdin

- name: Read image list from txt file
id: read_image_list
run: |
images=$(cat ./images.txt)
echo "::set-output name=images::$images"
- name: Pull and push images to Alibaba Cloud ACR
run: |
for image in ${{ steps.read_image_list.outputs.images }}; do
# Pull the image from DockerHub
docker pull $image
# Tag the image for ACR
acr_image="${{ secrets.ACR_REGISTRY }}/$image"
docker tag $image $acr_image
# Push the image to ACR
docker push $acr_image
done

0 comments on commit f82cd91

Please sign in to comment.