Skip to content

Add image(s)/tag(s) quay.io/calico/apiserver,quay.io/calico/cni,quay.io/calico/csi,quay.io/calico/ctl,quay.io/calico/kube-controllers,quay.io/calico/node,quay.io/calico/node-driver-registrar,quay.io/calico/pod2daemon-flexvol,quay.io/calico/typha/v3.29.0 or add full image(s) by @github-actions[bot] #1166

Add image(s)/tag(s) quay.io/calico/apiserver,quay.io/calico/cni,quay.io/calico/csi,quay.io/calico/ctl,quay.io/calico/kube-controllers,quay.io/calico/node,quay.io/calico/node-driver-registrar,quay.io/calico/pod2daemon-flexvol,quay.io/calico/typha/v3.29.0 or add full image(s) by @github-actions[bot]

Add image(s)/tag(s) quay.io/calico/apiserver,quay.io/calico/cni,quay.io/calico/csi,quay.io/calico/ctl,quay.io/calico/kube-controllers,quay.io/calico/node,quay.io/calico/node-driver-registrar,quay.io/calico/pod2daemon-flexvol,quay.io/calico/typha/v3.29.0 or add full image(s) by @github-actions[bot] #1166

name: Add tag to existing image
run-name: Add image(s)/tag(s) ${{ inputs.images }}/${{ inputs.tags }} or add full image(s) ${{ inputs.full_images }} by @${{ github.actor }}
on:
workflow_dispatch:
inputs:
full_images:
type: string
description: "Comma separated list of existing images with tags"
required: false
images:
type: string
description: "Comma separated list of existing images"
required: false
tags:
type: string
description: "Comma separated list of tags to add"
required: false
env:
FULL_IMAGES: ${{ inputs.full_images }}
IMAGES: ${{ inputs.images }}
TAGS: ${{ inputs.tags }}
permissions:
contents: write
pull-requests: write
jobs:
add-tag-to-existing-image:
runs-on: ubuntu-latest
steps:
- name: Check out repository code
uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4.2.2
- name: Run add-tag-to-existing-image.sh
if: github.event.inputs.images != '' && github.event.inputs.tags != ''
run: ./scripts/add-tag-to-existing-image.sh
- name: Run add-full-image-wrapper.sh
if: github.event.inputs.full_images != ''
run: ./scripts/add-full-image-wrapper.sh
- name: Check for repository changes
run: |
if git diff --name-only --exit-code; then
echo "No changes found in repository"
echo "changes_exist=false" >> $GITHUB_ENV
else
echo "Changes found in repository"
git diff --name-only
echo "changes_exist=true" >> $GITHUB_ENV
fi
- name: Create branch, commit and push
if: ${{ env.changes_exist == 'true' }}
id: branch
run: |
BRANCH="gha-add-tag-${GITHUB_RUN_ID}-${GITHUB_RUN_ATTEMPT}"
echo "branch=${BRANCH}" >> $GITHUB_OUTPUT
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --global user.name "github-actions[bot]"
git checkout -b "$BRANCH"
git commit -a -m "Adding new tag(s) for image(s) ${IMAGES}"
git push origin "$BRANCH"
- name: Create Pull Request
if: ${{ env.changes_exist == 'true' }}
id: cpr
env:
SOURCE_BRANCH: ${{ steps.branch.outputs.branch }}
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
if [ -n "${FULL_IMAGES}" ]; then
echo "Full Images: ${FULL_IMAGES}" >> $GITHUB_STEP_SUMMARY
PR_TITLE="Added image(s) ${FULL_IMAGES}"
PR_TITLE=$(echo "$PR_TITLE" | cut -c -256)
EXISTING_PR=$(gh pr list --limit 1500 --json title,url | jq --arg title "${PR_TITLE}" -r '.[] | select(.title==$title) | .url')
if [ -z "${EXISTING_PR}" ]; then
PR_BODY="$(echo -e Full Images: ${FULL_IMAGES}\\n\\nAuto-generated by GitHub Actions, initiated by @${GITHUB_ACTOR}\\n)"
CREATED_PR=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}" --label "status/auto-created" --base "${GITHUB_REF_NAME}" --head "${SOURCE_BRANCH}")
echo "Created pull request: ${CREATED_PR}" >> $GITHUB_STEP_SUMMARY
else
echo "Pull request already exists: ${EXISTING_PR}" >> $GITHUB_STEP_SUMMARY
fi
else
echo "Images: ${IMAGES}" >> $GITHUB_STEP_SUMMARY
echo "Tags: ${TAGS}" >> $GITHUB_STEP_SUMMARY
PR_TITLE="Added tag(s) ${TAGS} for image(s) ${IMAGES}"
PR_TITLE=$(echo "$PR_TITLE" | cut -c -256)
EXISTING_PR=$(gh pr list --limit 1500 --json title,url | jq --arg title "${PR_TITLE}" -r '.[] | select(.title==$title) | .url')
if [ -z "${EXISTING_PR}" ]; then
PR_BODY="$(echo -e Images: ${IMAGES}\\nTags: ${TAGS}\\n\\nAuto-generated by GitHub Actions, initiated by @${GITHUB_ACTOR}\\n)"
CREATED_PR=$(gh pr create --title "${PR_TITLE}" --body "${PR_BODY}" --label "status/auto-created" --base "${GITHUB_REF_NAME}" --head "${SOURCE_BRANCH}")
echo "Created pull request: ${CREATED_PR}" >> $GITHUB_STEP_SUMMARY
else
echo "Pull request already exists: ${EXISTING_PR}" >> $GITHUB_STEP_SUMMARY
fi
fi