iStore PR check #128
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: iStore PR check | |
on: | |
pull_request_target: | |
types: [opened, synchronize, reopened, edited] | |
branches: [main] | |
merge_group: | |
types: [checks_requested] | |
env: | |
TZ: Asia/Shanghai | |
jobs: | |
check: | |
if: | | |
github.event_name == 'merge_group' || | |
(github.event.action != 'edited' || github.event.changes.base.ref.from != github.event.pull_request.base.ref) | |
runs-on: ubuntu-latest | |
name: PR Validate | |
steps: | |
- name: Dump GitHub context | |
env: | |
GITHUB_CONTEXT: ${{ toJson(github) }} | |
run: echo "$GITHUB_CONTEXT" | |
- name: Checkout base on PR to pending | |
if: github.event_name != 'merge_group' && github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name | |
uses: actions/checkout@main | |
with: | |
fetch-depth: 1 | |
path: 'base' | |
- name: Checkout head on PR to pending | |
if: github.event_name != 'merge_group' && github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name | |
uses: actions/checkout@main | |
with: | |
ref: ${{ github.event.pull_request.head.sha }} | |
fetch-depth: 1 | |
path: 'head' | |
- name: Check workflows changes on PR to pending | |
if: github.event_name != 'merge_group' && github.event.pull_request.base.repo.full_name != github.event.pull_request.head.repo.full_name | |
run: | | |
[ -d base/.github/workflows ] | |
[ -d head/.github/workflows ] | |
rm -rf base/.github/workflows | |
cp -a head/.github/workflows base/.github/ | |
if git -C base diff --pretty= --name-only --no-renames | grep '^.github/workflows/'; then \ | |
echo "Don't HACK my workflows!" >&2; \ | |
echo "::error title=PR Check failed::Don't touch workflows!"; \ | |
exit 1; \ | |
else \ | |
true; \ | |
fi | |
- name: Check pass | |
run: | | |
echo "PASS" | |
true | |