Add 2.0.x branch for play-file-watch #161
Workflow file for this run
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: Repos Validation | |
on: | |
pull_request_target: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: checkout fork | |
uses: actions/checkout@v2 | |
with: | |
repo: ${{ github.event.pull_request.head.repo.full_name }} | |
ref: ${{ github.event.pull_request.head.sha }} | |
- name: copy fork repos-*.md | |
run: | | |
mkdir -p /tmp/fork | |
cp repos*.md /tmp/fork | |
- name: checkout origin | |
uses: actions/checkout@v2 | |
with: | |
ref: ${{ github.event.pull_request.base.sha }} | |
- name: copy origin repos-*.md | |
run: | | |
mkdir -p /tmp/origin | |
cp repos*.md /tmp/origin | |
- id: calc_diff | |
name: diff | |
run: | | |
LINKS="" | |
GITHUB_CHANGES=$(git diff --unified=0 --output-indicator-new=# --output-indicator-old=# /tmp/fork/repos-github.md /tmp/origin/repos-github.md || echo "") | |
if [[ $? -ne 0 ]]; then | |
echo "git error!" | |
exit 1; | |
fi | |
if [[ "$GITHUB_CHANGES" ]]; then | |
GITHUB_CHANGES=$(echo "$GITHUB_CHANGES" | grep '^#' | sed 's/#- //' | uniq) | |
while IFS= read -r owner_repo; do | |
if [[ $owner_repo == ${{ github.actor }}/* ]]; then | |
VALIDATION="✅" | |
else | |
owner=$(curl --silent \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Referer: https://github.com" \ | |
https://api.github.com/repos/$owner_repo | jq ".owner" | |
) | |
if [[ $(echo $owner | jq --raw-output ".type") == 'Organization' ]]; then | |
org=$(echo $owner | jq --raw-output ".login") | |
org_admins=$(curl --silent \ | |
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
-H "Accept: application/vnd.github.v3+json" \ | |
-H "Referer: https://github.com" \ | |
https://api.github.com/orgs/$org/members?role=admin | jq --raw-output ".[].login" | |
) | |
if echo "$org_admins" | grep '^${{ github.actor}}$'; then | |
VALIDATION="✅" | |
else | |
VALIDATION="❔" | |
fi | |
else | |
VALIDATION="❔" | |
fi | |
fi | |
LINKS+=$'\n'"$VALIDATION [$owner_repo](https://github.com/$owner_repo)" | |
done <<< "$GITHUB_CHANGES" | |
fi | |
GITLAB_CHANGES=$(git diff --unified=0 --output-indicator-new=# --output-indicator-old=# /tmp/fork/repos-gitlab.md /tmp/origin/repos-gitlab.md || echo "") | |
if [[ "$GITLAB_CHANGES" ]]; then | |
GITLAB_CHANGES=$(echo "$GITLAB_CHANGES" | grep '^#' | sed 's/#- //' | uniq) | |
while IFS= read -r owner_repo; do | |
if [[ $owner_repo == ${{ github.actor }}/* ]]; then | |
VALIDATION="✅" | |
else | |
VALIDATION="❔" | |
fi | |
LINKS+=$'\n'"$VALIDATION [$owner_repo](https://gitlab.com/$owner_repo)" | |
done <<< "$GITLAB_CHANGES" | |
fi | |
BITBUCKET_CHANGES=$(git diff --unified=0 --output-indicator-new=# --output-indicator-old=# /tmp/fork/repos-bitbucket.md /tmp/origin/repos-bitbucket.md || echo "") | |
if [[ "$BITBUCKET_CHANGES" ]]; then | |
BITBUCKET_CHANGES=$(echo "$BITBUCKET_CHANGES" | grep '^#' | sed 's/#- //' | uniq) | |
while IFS= read -r owner_repo; do | |
if [[ $owner_repo == ${{ github.actor }}/* ]]; then | |
VALIDATION="✅" | |
else | |
VALIDATION="❔" | |
fi | |
LINKS+=$'\n'"$VALIDATION [$owner_repo](https://bitbucket.org/$owner_repo)" | |
done <<< "$BITBUCKET_CHANGES" | |
fi | |
echo "$LINKS" | |
LINKS="${LINKS//'%'/'%25'}" | |
LINKS="${LINKS//$'\n'/'%0A'}" | |
LINKS="${LINKS//$'\r'/'%0D'}" | |
echo "::set-output name=LINKS::${LINKS}" | |
- name: found diff | |
id: non-empty | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ steps.calc_diff.outputs.LINKS }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
message: | | |
Changed repositories: | |
${{ steps.calc_diff.outputs.LINKS }} | |
Legends: | |
✅=Actor is a repo owner or an organization admin. | |
❔=Unable to validate. Requires manual validation. | |
- name: no updates | |
id: no-updates | |
uses: marocchino/sticky-pull-request-comment@v2 | |
if: ${{ steps.calc_diff.outputs.LINKS == '' }} | |
with: | |
github_token: ${{ secrets.github_token }} | |
message: | | |
No changes found on repos. |