2024-08-30 - Fixes nil words returning #8
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: Validate and Merge Pull Request | |
on: | |
pull_request: | |
types: [opened, synchronize] | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
BOT_ACCESS_TOKEN: ${{ secrets.BOT_ACCESS_TOKEN }} | |
permissions: | |
contents: write | |
pull-requests: write | |
jobs: | |
merge: | |
runs-on: ubuntu-22.04 | |
if: contains(github.event.pull_request.labels.*.name, 'mb-cli') | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Install Node.js | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '18' | |
- name: Run Validation Script | |
id: validation | |
run: | | |
node ./.github/scripts/validation.js ./Sources/PhraseKit/Resources pending | |
- name: Commit Changes | |
if: success() | |
run: | | |
git config --global user.name "mb-actions[bot]" | |
git config --global user.email "[email protected]" | |
git add . | |
git commit -m "Auto-update JSON files after validation" | |
git pull origin ${{ github.event.pull_request.head.ref }} --rebase | |
git push origin HEAD:${{ github.event.pull_request.head.ref }} | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
- name: Merge Pull Request | |
if: success() | |
run: | | |
gh pr merge ${{ github.event.pull_request.number }} --admin --delete-branch --merge | |
env: | |
GITHUB_TOKEN: ${{ env.BOT_ACCESS_TOKEN }} | |
- name: Update PR (Success) | |
if: success() | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ env.GITHUB_TOKEN }} | |
script: | | |
const fs = require('fs'); | |
const outputPath = 'validation_output.txt'; | |
let output = ''; | |
if (fs.existsSync(outputPath)) { | |
output = fs.readFileSync(outputPath, 'utf8'); | |
} else { | |
output = 'No output generated from validation.'; | |
} | |
github.pulls.createReview({ | |
pull_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Word validation was successful with the following details:\n\`\`\`\n${output}\n\`\`\`\n`, | |
event: "COMMENT" | |
}); | |
- name: Update PR (Failure) | |
if: failure() | |
uses: actions/github-script@v4 | |
with: | |
github-token: ${{ env.GITHUB_TOKEN }} | |
script: | | |
github.pulls.createReview({ | |
pull_number: context.payload.pull_request.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: `Validation failed. Please check the details and make necessary changes.`, | |
event: "REQUEST_CHANGES" | |
}); |