[오늘의 알고리즘] 문자열 집합 #58
This file contains hidden or 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: Algoritm PR File Mover | |
| on: | |
| pull_request: | |
| types: [ "closed" ] | |
| branches: [ "main" ] | |
| jobs: | |
| file-mover: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout Repository | |
| uses: actions/checkout@master | |
| with: | |
| fetch-depth: 0 | |
| - name: Get PR Infos | |
| run: | | |
| algorithm=$((curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \ | |
| https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/labels | \ | |
| jq '.[] | select(.name=="Algorithm") .name') || echo '') | |
| echo "IS_ALGORITHM=$algorithm" >> $GITHUB_ENV | |
| echo "PR_AUTHOR=$(jq --raw-output .pull_request.user.login $GITHUB_EVENT_PATH)" >> $GITHUB_ENV | |
| - name: Move Files | |
| if: ${{ env.IS_ALGORITHM && github.event.pull_request.merged }} | |
| run: | | |
| git config --global user.email "bug60t@gmail.com" | |
| git config --global user.name "bugs-bot" | |
| git config --global core.quotepath off | |
| mkdir -p $PR_AUTHOR | |
| files=$(git diff --name-only HEAD^..HEAD | grep -v "^$PR_AUTHOR") | |
| echo "$files" | tr '\n' '\0' | xargs -0 -I {} mv "{}" $PR_AUTHOR/ | |
| git add -A && git commit --amend --no-edit --allow-empty | |
| git push --force-with-lease |