3535 id : changes
3636 run : echo "files=$(git diff --name-only ${{ github.event.before }} ${{ github.sha }} | tr '\n' ' ')" >> $GITHUB_ENV
3737
38- - name : Write Docker versions to file
39- # This step writes the Docker and Docker Compose versions to a file
40- run : |
41- echo "- $(docker --version)" > docker-versions.txt
42- echo "- $(docker compose version)" >> docker-versions.txt
43-
4438 - name : Authenticate GH CLI
4539 # This step authenticates the GitHub CLI
4640 run : gh auth login --with-token <<< "${{ secrets.GITHUB_TOKEN }}"
@@ -50,14 +44,35 @@ jobs:
5044 run : |
5145 git config --global user.name 'GitHub Action'
5246 git config --global user.email '[email protected] ' 53- git checkout -b docker-versions-update
47+
48+ # Ensure we start from a clean main branch
49+ git fetch origin main
50+ git checkout main
51+ git reset --hard origin/main
52+
53+ # Create unique branch name to avoid conflicts
54+ BRANCH_NAME="docker-versions-update-$(date +%s)"
55+ git checkout -b "$BRANCH_NAME"
56+
57+ # Write Docker versions to file
58+ echo "- $(docker --version)" > docker-versions.txt
59+ echo "- $(docker compose version)" >> docker-versions.txt
60+
61+ # Only add the specific file we want
5462 git add docker-versions.txt
55- if git diff-index --quiet HEAD --; then
56- echo "No changes to commit"
63+
64+ # Check if there are actually changes to commit
65+ if git diff --cached --quiet; then
66+ echo "No changes to docker-versions.txt, skipping PR creation"
5767 else
58- git commit -m "Update Docker versions"
59- git push origin docker-versions-update
60- echo 'y' | gh pr create --fill
68+ git commit -m "chore: update Docker versions
69+ git push origin "$BRANCH_NAME"
70+ # Create PR with explicit title and body instead of --fill
71+ gh pr create \
72+ --title "chore: update Docker versions" \
73+ --body "Automated update of docker-versions.txt with current Docker and Docker Compose versions.
74+ --base main \
75+ --head "$BRANCH_NAME"
6176 fi
6277
6378 - name : Check for Dockerfile and context changes
0 commit comments