[GAL] week12 23829,16974,15926,32031 #2
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: Create Galgorithm directories | |
on: | |
issues: | |
types: [opened] | |
jobs: | |
GAL: | |
runs-on: ubuntu-latest | |
if: "startsWith(github.event.issue.title, '[GAL]')" | |
permissions: | |
write-all | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Validate issue format | |
run: | | |
ISSUE_TITLE="${{ github.event.issue.title }}" | |
id=("burningfalls" "donghoony" "hjk0761" "hw0603" "hyxrxn" "jminkkk" "robinjoon" "slimsha2dy") | |
if [[ ! "$ISSUE_TITLE" =~ ^\[GAL\]\ ([a-zA-Z0-9_-]+)\ ([0-9]+[,[0-9]+]*)$ ]]; then | |
echo "Issue title format is incorrect." | |
exit 1 | |
fi | |
DIRNAME="${BASH_REMATCH[1]}" | |
NUMBERS="${BASH_REMATCH[2]}" | |
IFS=',' read -ra NUM_ARRAY <<< "$NUMBERS" | |
for NUM in "${NUM_ARRAY[@]}"; do | |
mkdir -p "${DIRNAME}/${NUM}" | |
for GID in "${id[@]}"; do | |
mkdir -p "${DIRNAME}/${NUM}/${GID}" | |
echo -e "# Info\n[Link](https://boj.kr/${NUM})\n## 💡 풀이 방법 요약\n\n## 👀 실패 이유\n\n## 🙂 마무리" > "${DIRNAME}/${NUM}/${GID}/README.md" | |
done | |
done | |
- name: Check if issue creator is in allowed list | |
id: check_creator | |
run: | | |
ISSUE_CREATOR="${{ github.event.issue.user.login }}" | |
id=("burningfalls" "donghoony" "hjk0761" "hw0603" "hyxrxn" "jminkkk" "robinjoon" "slimsha2dy") | |
if [[ " ${id[@]} " =~ " $ISSUE_CREATOR " ]]; then | |
echo "allowed=true" >> $GITHUB_ENV | |
else | |
echo "allowed=false" >> $GITHUB_ENV | |
fi | |
- name: Push changes if allowed | |
if: env.allowed == 'true' | |
run: | | |
git config --local user.email "[email protected]" | |
git config --local user.name "GitHub Actions" | |
git add . | |
git commit -m "Create directories and files for GAL issue: ${{ github.event.issue.number }}" | |
git push | |
- name: Close issue after pushing | |
uses: peter-evans/close-issue@v3 | |
with: | |
issue-number: ${{ github.event.issue.number }} | |
comment: | | |
Created directories, closing issue. |