docker.io/mongo:6.0.2 #26
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: List Image Tags | |
on: | |
issues: | |
types: [opened, edited] | |
permissions: | |
issues: write | |
jobs: | |
list-tags: | |
runs-on: ubuntu-24.04 | |
permissions: | |
issues: write | |
if: contains(github.event.issue.labels.*.name, 'list tags') | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Check Issue | |
run: | | |
gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }} | |
ORIGIN_IMAGE=$(echo "${{ github.event.issue.title }}" | awk '{print $1}') | |
if [[ -z "${ORIGIN_IMAGE}" ]]; then | |
gh issue comment ${{ github.event.issue.number }} -b "Image not found." | |
exit 1 | |
fi | |
if [[ "${ORIGIN_IMAGE%%/*}" != *"."* ]]; then | |
gh issue comment ${{ github.event.issue.number }} -b "镜像 ${ORIGIN_IMAGE} 格式不正确。<br> 请指定域名, 如: docker.io/${ORIGIN_IMAGE}" | |
exit 1 | |
fi | |
- name: List image tags | |
run: | | |
gh auth login --with-token <<< ${{ secrets.GITHUB_TOKEN }} | |
ORIGIN_IMAGE=$(echo "${{ github.event.issue.title }}" | awk '{print $1}') | |
LIST_IMAGE_JSON=$(skopeo list-tags docker://${ORIGIN_IMAGE} | jq -r '.Tags[] | select(test("\\d+\\.\\d"))' | sort -Vr | head -n 30) | |
gh issue comment ${{ github.event.issue.number }} -b "$LIST_IMAGE_JSON" | |
gh issue close ${{ github.event.issue.number }} --reason "completed" |