Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create readme-check.yml #138

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 35 additions & 0 deletions .github/workflows/readme-check.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Check for README.md and LISEZMOI.md

on:
push:
branches: [action-trigger]
workflow_dispatch:

jobs:
readme-check:
runs-on: ubuntu-latest
steps:
- name: Get list of repos
env:
TOKEN: ${{ secrets.MY_PAT }}
run: |
result=`curl -H "Authorization: $TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/orgs/OpenDRR/repos?per_page=100 | jq .[].name | tr -d \"`
results=($result)
for REPO in "${results[@]}"
do
RESPONSE=`curl -i https://api.github.com/repos/OpenDRR/$REPO/contents/README.md --write-out "%{http_code}\n" --output /dev/null --silent`
FRESPONSE=`curl -i -H "Authorization: $TOKEN" https://api.github.com/repos/OpenDRR/$REPO/contents/LISEZMOI.md --write-out "%{http_code}\n" --output /dev/null --silent`
if [ $RESPONSE == 404 ] && [ $FRESPONSE == 404 ]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I would suggest using double square brackets, i.e. [[ $RESPONSE == 404 ]] && [[ $FRESPONSE == 404 ]] as otherwise the variables need to be double-quoted. In ShellCheck's words: SC2086 (info): Double quote to prevent globbing and word splitting.

then
curl -X POST -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OpenDRR/$REPO/issues -d '{"title":"Add README.md and LISEZMOI.md files"}'
echo Issue to add README.md and LISEZMOI.md created in $REPO
elif [ $FRESPONSE == 404 ]
then
curl -X POST -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OpenDRR/$REPO/issues -d '{"title":"Add LISEZMOI.md file"}'
echo Issue to add LISEZMOI.md created in $REPO
elif [ $RESPONSE == 404 ]
then
curl -X POST -H "Authorization: token $TOKEN" -H "Accept: application/vnd.github.v3+json" https://api.github.com/repos/OpenDRR/$REPO/issues -d '{"title":"Add README.md file"}'
echo Issue to add README.md created in $REPO
fi
done