Merge pull request #241 from sheril5/main #79
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: Docker Image CI | |
on: | |
push: | |
paths: | |
- 'images/**' | |
branches: [ main ] | |
env: | |
# Use docker.io for Docker Hub if empty | |
REGISTRY: ghcr.io | |
# github.repository as <account>/<repo> | |
IMAGE_NAME: ${{ github.repository }} | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
- name: Docker push | |
run: | | |
# Log in to GitHub Container Registry | |
docker login ${{ env.REGISTRY }} -u jebinjeb -p ${{ secrets.GITHUB_TOKEN }} | |
while IFS= read -r image; do | |
# Check if the image is from docker.io | |
docker pull "$image" | |
# Tag the image with the GitHub repository URL | |
github_image="ghcr.io/$GITHUB_REPOSITORY/$(echo "$image" | awk -F '/' '{print $NF}')" | |
docker tag "$image" "$github_image" | |
# Push the image to GitHub Container Registry | |
docker push "$github_image" | |
if [ $? -eq 0 ]; then | |
echo "Image pushed successfully" | |
else | |
echo "retry" | |
docker push "$github_image" | |
fi | |
done < images/capten-images.txt |