mirror of
https://github.com/actions/runner.git
synced 2026-08-03 09:52:46 +08:00
Fix Docker Buildx update reruns
Co-authored-by: Copilot App <223556219+Copilot@users.noreply.github.com> Copilot-Session: 548ba3f7-0d56-4966-ad57-1b9ace7534f6
This commit is contained in:
49
.github/workflows/docker-buildx-upgrade.yml
vendored
49
.github/workflows/docker-buildx-upgrade.yml
vendored
@@ -51,7 +51,20 @@ jobs:
|
||||
current_version=$(grep "ARG BUILDX_VERSION=" ./images/Dockerfile | cut -d'=' -f2)
|
||||
|
||||
# Fetch latest Buildx version
|
||||
latest_version=$(curl -s https://api.github.com/repos/docker/buildx/releases/latest | jq -r '.tag_name' | sed 's/^v//')
|
||||
latest_response=$(curl -fsSL https://api.github.com/repos/docker/buildx/releases/latest) || {
|
||||
echo "Failed to retrieve Buildx release information"
|
||||
exit 1
|
||||
}
|
||||
latest_version=$(jq -er '.tag_name | sub("^v"; "")' <<< "$latest_response") || {
|
||||
echo "Failed to retrieve a valid Buildx version"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Extra check to ensure we got a valid version
|
||||
if [[ ! $latest_version =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then
|
||||
echo "Failed to retrieve a valid Buildx version"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
should_update=false
|
||||
[ "$current_version" != "$latest_version" ] && should_update=true
|
||||
@@ -91,6 +104,12 @@ jobs:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v7
|
||||
|
||||
- name: Create update branch
|
||||
shell: bash
|
||||
run: |
|
||||
branch_name="feature/docker-buildx-upgrade"
|
||||
git checkout -B "$branch_name"
|
||||
|
||||
- name: Update Docker version
|
||||
if: ${{ needs.check-versions.outputs.DOCKER_SHOULD_UPDATE == 'true' }}
|
||||
shell: bash
|
||||
@@ -141,14 +160,6 @@ jobs:
|
||||
git config --global user.name "github-actions[bot]"
|
||||
git config --global user.email "<41898282+github-actions[bot]@users.noreply.github.com>"
|
||||
|
||||
# Create branch or switch to it if it exists
|
||||
if git show-ref --quiet refs/remotes/origin/$branch_name; then
|
||||
git fetch origin
|
||||
git checkout -B "$branch_name" origin/$branch_name
|
||||
else
|
||||
git checkout -b "$branch_name"
|
||||
fi
|
||||
|
||||
# Commit and push changes
|
||||
git commit -a -m "$commit_message"
|
||||
git push --force origin "$branch_name"
|
||||
@@ -185,11 +196,15 @@ jobs:
|
||||
echo "Autogenerated by [Docker/Buildx Version Upgrade Workflow](https://github.com/actions/runner/blob/main/.github/workflows/docker-buildx-upgrade.yml)"
|
||||
} > pr_body.txt
|
||||
|
||||
# Create PR
|
||||
gh pr create -B main -H "$branch_name" \
|
||||
--title "$pr_title" \
|
||||
--label "dependencies" \
|
||||
--label "dependencies-weekly-check" \
|
||||
--label "dependencies-not-dependabot" \
|
||||
--label "docker" \
|
||||
--body-file pr_body.txt
|
||||
existing_pr=$(gh pr list --head "$branch_name" --state open --json number --jq '.[0].number // ""')
|
||||
if [[ -n "$existing_pr" ]]; then
|
||||
gh pr edit "$existing_pr" --title "$pr_title" --body-file pr_body.txt
|
||||
else
|
||||
gh pr create -B main -H "$branch_name" \
|
||||
--title "$pr_title" \
|
||||
--label "dependencies" \
|
||||
--label "dependencies-weekly-check" \
|
||||
--label "dependencies-not-dependabot" \
|
||||
--label "docker" \
|
||||
--body-file pr_body.txt
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user