branch/feat-caos-as-a-service #20
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: Issue to Empty Commit | |
| on: | |
| issues: | |
| types: [opened, edited] | |
| permissions: | |
| contents: write | |
| issues: write | |
| jobs: | |
| issue_to_commit: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout repo | |
| uses: actions/checkout@v4 | |
| - name: Extract issue data | |
| run: | | |
| jq . "$GITHUB_EVENT_PATH" > event.json | |
| echo "ISSUE_NUMBER=$(jq -r .issue.number event.json)" >> $GITHUB_ENV | |
| echo "ISSUE_TITLE=$(jq -r .issue.title event.json)" >> $GITHUB_ENV | |
| jq -r .issue.body event.json > issue_body.txt | |
| - name: Generate commit message | |
| run: | | |
| echo "issue(#$ISSUE_NUMBER): $ISSUE_TITLE" > commit_message.txt | |
| echo "" >> commit_message.txt | |
| echo "Issue link: https://github.com/$GITHUB_REPOSITORY/issues/$ISSUE_NUMBER" >> commit_message.txt | |
| echo "" >> commit_message.txt | |
| echo "Body:" >> commit_message.txt | |
| cat issue_body.txt >> commit_message.txt | |
| echo "Commit message:" | |
| cat commit_message.txt | |
| - name: Configure git | |
| run: | | |
| git config user.name "issue-bot" | |
| git config user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
| - name: Create empty commit | |
| run: | | |
| git commit --allow-empty -F commit_message.txt || echo "nothing to commit" | |
| - name: Push commit | |
| run: | | |
| git push origin HEAD:main | |
| - name: Close issue | |
| run: | | |
| curl -s -X PATCH \ | |
| -H "Accept: application/vnd.github+json" \ | |
| -H "Authorization: Bearer ${{ secrets.GITHUB_TOKEN }}" \ | |
| https://api.github.com/repos/${{ github.repository }}/issues/${ISSUE_NUMBER} \ | |
| -d '{"state":"closed","state_reason":"completed"}' |