Skip to content

created introduction file - Justin Bowers #168

created introduction file - Justin Bowers

created introduction file - Justin Bowers #168

name: Verify new student PRs
permissions:
actions: write
checks: write
contents: read
pull-requests: write
statuses: write
on:
# Event `pull_request`: Compare the last commit of the main branch or last remote commit of the PR branch -> to the current commit of a PR branch.
pull_request_target:
branches:
- master
- main
paths:
- '*.md'
jobs:
changed_only_netid:
runs-on: ubuntu-latest
name: Test netid file
steps:
- run: |
echo "pr merge_commit_sha: ${{ github.event.pull_request.merge_commit_sha }}"
echo "pr_target merge_commit_sha: ${{ github.event.pull_request_target.merge_commit_sha }}"
echo "pr event data: ${{ toJson(github.event.pull_request) }}"
echo "pr_target event data: ${{ toJson(github.event.pull_request_target) }}"
- uses: actions/checkout@v3
with:
fetch-depth: 20
ref: "${{ github.event.pull_request.merge_commit_sha }}"
- run: |
git show HEAD
ls -lah
#- uses: jwalton/gh-find-current-pr@v1
# id: prfinder
#- run: echo "Your PR is ${PR}"
# if: success() && steps.findPr.outputs.number
# env:
# PR_NUMBER: ${{ steps.findPr.outputs.pr }}
- name: Get the files that were changed.
id: changed-files
uses: tj-actions/changed-files@v37
with:
files_yaml: |
everything:
- '*'
netids:
- '[a-z]*.md'
- name: List all changed files
run: |
for file in ${{ steps.changed-files.outputs.everything_all_changed_files }}; do
echo "changed: $file"
done
- name: Assert only one file was changed.
# NOTE: Ensure all outputs are prefixed by the same key used above e.g. `test_(...)` | `doc_(...)` | `src_(...)` when trying to access the `any_changed` output.
if: steps.changed-files.outputs.everything_all_changed_files_count != 1
run: |
echo "::error::More than one file was changed." && exit 1
- name: Assert file changed was a netid file.
if: steps.changed-files.outputs.netids_all_changed_files_count != 1
run: |
echo "::error::Changed a file other than your netid markdown." && exit 1
# SECURITY NOTE: don't run any in-repo scripts before this, due to checkout of remote code
# The above tests ensure only the markdown file was changed.
- name: Verify file using scripts
run: |
python -m scripts.settings
- name: Run script with netid and GH name
run: |
python -m scripts.pr_actions_handler ${{ github.event.pull_request.user.login }} ${{ steps.changed-files.outputs.netids_all_changed_and_modified_files }}
- name: Run scripts to update files
run: |
python -m scripts.student-names-from-bios
python -m scripts.make-NetID2GHID > NetID2GHID.md
- name: Show computed changes from script runs
run: |
echo "## Change preview" >> FDAC_STUDENT_PR_CHANGES.comment
echo "Make sure your name and username are correct!" >> FDAC_STUDENT_PR_CHANGES.comment
echo "" >> FDAC_STUDENT_PR_CHANGES.comment
echo '```patch' >> FDAC_STUDENT_PR_CHANGES.comment
git diff --patch | tee -a FDAC_STUDENT_PR_CHANGES.comment
echo '```' >> FDAC_STUDENT_PR_CHANGES.comment
id: gitdiff
- uses: marocchino/sticky-pull-request-comment@v2
with:
header: newstudent
path: FDAC_STUDENT_PR_CHANGES.comment