-
Notifications
You must be signed in to change notification settings - Fork 12
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
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
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 |