Minor updates to checklist BG Chapter 6 #977
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: Manual Build Validation | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
validate: | |
runs-on: ubuntu-latest | |
# Check if PR, prevent running on forks and trigger comment | |
if: ${{ github.event.issue.pull_request && github.repository_owner == 'flybywiresim' && github.event.comment.body == 'check build' }} | |
steps: | |
- name: Check if user is member of organization and maintainer | |
id: check-permissions | |
uses: actions/github-script@v6 | |
with: | |
result-encoding: string | |
script: | | |
const { owner } = context.repo; | |
const { data: members } = await github.rest.orgs.listMembers({ | |
org: owner, | |
per_page: 100, | |
}); | |
const { data: isOrgMember } = members.find(member => member.login === context.payload.comment.user.login) || { data: false }; | |
const { data: isMaintainer } = await github.rest.repos.getCollaboratorPermissionLevel({ | |
owner: owner, | |
repo: context.repo.repo, | |
username: context.payload.comment.user.login, | |
}); | |
return isOrgMember === true && isMaintainer.permission === 'maintain' | |
- name: React to comment | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
const {owner, repo} = context.issue; | |
github.rest.reactions.createForIssueComment({ | |
owner, | |
repo, | |
comment_id: context.payload.comment.id, | |
content: "rocket", | |
}); | |
- name: Get PR SHA | |
id: sha | |
uses: actions/github-script@v6 | |
with: | |
result-encoding: string | |
script: | | |
const { owner, repo, number } = context.issue; | |
const pr = await github.rest.pulls.get({ | |
owner, | |
repo, | |
pull_number: number, | |
}); | |
return pr.data.head.sha | |
- uses: actions/checkout@v3 | |
with: | |
ref: ${{ steps.sha.outputs.result }} | |
fetch-depth: 0 | |
- name: Make Build | |
uses: actions/setup-python@v4 | |
with: | |
python-version: 3.x | |
- run: | | |
pip install -r requirements.txt | |
mkdocs build -s | |
- name: Message success | |
if: ${{ success() }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Strict Build Validated! ✅', | |
}); | |
- name: Message failure | |
if: ${{ failure() }} | |
uses: actions/github-script@v6 | |
with: | |
script: | | |
github.rest.issues.createComment({ | |
issue_number: context.issue.number, | |
owner: context.repo.owner, | |
repo: context.repo.repo, | |
body: 'Strict Build Failed! ❌ - Please checkout this PR locally to fix the issue before merging or visit the actions tab.', | |
}); |