Create dockerhub-proxy.md #7
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: CI | |
on: | |
workflow_dispatch: | |
push: | |
branches: | |
- main | |
jobs: | |
test-docker-pull: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Read and process dockerhub-proxy.md | |
id: read_file | |
run: | | |
# Read the file and process each line | |
urls=() | |
while IFS= read -r line; do | |
# Remove '- https://' prefix and append to urls array | |
url="${line/- https:\/\//}" | |
urls+=("$url") | |
done < docs/reference/_include/dockerhub-proxy.md | |
# Print the array for debugging | |
echo "Processed URLs: ${urls[@]}" | |
# Save the array to the outputs | |
echo "::set-output name=urls::${urls[*]}" | |
- name: Docker pull from proxies | |
run: | | |
# Read the URLs from the previous step | |
urls="${{ steps.read_file.outputs.urls }}" | |
IFS=' ' read -r -a url_array <<< "$urls" | |
# Try to pull the image from each URL | |
for url in "${url_array[@]}"; do | |
echo "Trying to pull from $url/library/mysql:5.7" | |
docker pull "$url/library/mysql:5.7" && echo "Successfully pulled from $url" | |
if [ $? -eq 0 ]; then | |
echo "Deleting the pulled image to ensure fresh pull for the next URL" | |
docker rmi "$url/library/mysql:5.7" | |
else | |
echo "Failed to pull from $url" | |
fi | |
done |