registry.k8s.io/etcd:3.5.15-0 #177
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: Mirror Porter | |
on: | |
issues: | |
types: [opened, reopened, edited] | |
jobs: | |
mirror-porter-job: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check if Issue Author Starred the Repo | |
id: check-star | |
run: | | |
echo "Checking if ${{ github.event.issue.user.login }} starred the repo" | |
author=${{ github.event.issue.user.login }} | |
page=1 | |
per_page=100 | |
found="false" | |
while [ "$found" == "false" ]; do | |
response=$(curl -s "https://api.github.com/repos/myifeng/mirror-porter/stargazers?per_page=$per_page&page=$page") | |
logins=$(echo "$response" | jq -r '.[].login') | |
if echo "$logins" | grep -w $author > /dev/null; then | |
found="true" | |
echo "::set-output name=starred::${author}" | |
elif [ $(echo "$logins" | wc -l) -lt $per_page ]; then | |
break | |
else | |
page=$((page + 1)) | |
fi | |
done | |
if [ "$found" == "false" ]; then | |
echo "::set-output name=starred::" | |
fi | |
- id: Checkout | |
uses: actions/checkout@v3 | |
if: steps.check-star.outputs.starred != '' | |
- name: Generate image name | |
id: generate_image_name | |
if: steps.check-star.outputs.starred != '' | |
run: | | |
source_image=${{ github.event.issue.title }} | |
target_image=${{ secrets.DOCKERHUB_USERNAME }}/${source_image//\//_} | |
echo "::set-output name=source_image::$source_image" | |
echo "::set-output name=source_image_name::${source_image%:*}" | |
echo "::set-output name=target_image::$target_image" | |
echo "::set-output name=target_image_name::${target_image%:*}" | |
- name: Copy image | |
id: pull-push | |
if: steps.check-star.outputs.starred != '' | |
run: | | |
docker run quay.io/skopeo/stable:latest copy -a --preserve-digests --remove-signatures --dest-username ${{ secrets.DOCKERHUB_USERNAME }} --dest-password ${{ secrets.DOCKERHUB_PASSWORD }} docker://${{ steps.generate_image_name.outputs.source_image }} docker://${{ steps.generate_image_name.outputs.target_image }} | |
- name: Close issue by success | |
uses: actions-cool/issues-helper@v3 | |
if: always() && steps.pull-push.outcome == 'success' && steps.check-star.outputs.starred != '' | |
with: | |
actions: "create-comment,add-labels,close-issue" | |
labels: ${{ steps.pull-push.outcome }} | |
issue-number: ${{ github.event.issue.number }} | |
close-reason: 'completed' | |
body: | | |
Hi @${{ github.event.issue.user.login }} | |
Now, you can use `${{ steps.generate_image_name.outputs.source_image }}` in [`${{ steps.generate_image_name.outputs.target_image }}`](https://hub.docker.com/r/${{ steps.generate_image_name.outputs.target_image_name }}) | |
```shell | |
docker pull ${{ steps.generate_image_name.outputs.target_image }} | |
``` | |
```shell | |
docker tag ${{ steps.generate_image_name.outputs.target_image }} ${{ steps.generate_image_name.outputs.source_image }} | |
``` | |
- name: Close issue by failure | |
uses: actions-cool/issues-helper@v3 | |
if: always() && steps.pull-push.outcome != 'success' && steps.check-star.outputs.starred != '' | |
with: | |
actions: "create-comment,add-labels,close-issue" | |
labels: ${{ steps.pull-push.outcome }} | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Sorry @${{ github.event.issue.user.login }} , it seems to fail here. | |
Please check if the title of the issue is in `image:tag` format. | |
- name: Docker Hub Description | |
uses: peter-evans/dockerhub-description@v2 | |
if: always() && steps.pull-push.outcome == 'success' | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
repository: ${{ steps.generate_image_name.outputs.target_image_name }} | |
readme-filepath: ./README.md | |
short-description: ${{ steps.generate_image_name.outputs.source_image_name }} | |
- name: Remove issue labels | |
uses: actions-cool/issues-helper@v3 | |
if: always() && steps.check-star.outputs.starred != '' | |
with: | |
actions: "remove-labels" | |
labels: "no-starred" | |
issue-number: ${{ github.event.issue.number }} | |
- name: Close issue by no-starred | |
uses: actions-cool/issues-helper@v3 | |
if: always() && steps.check-star.outputs.starred == '' | |
with: | |
actions: "create-comment,add-labels,close-issue" | |
labels: "no-starred" | |
issue-number: ${{ github.event.issue.number }} | |
body: | | |
Sorry @${{ github.event.issue.user.login }} , you have not starred this repository ! | |
Please `star` this repository and then `reopen` this issue to retry ! |