Workflow to check we have a paper trail on répertoire changes #22
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: Pipeline | |
on: | |
pull_request: | |
branches: ['*'] | |
types: [opened, synchronize, reopened, labeled, unlabeled, ready_for_review, converted_to_draft] | |
jobs: | |
labels-for-repertoire-changes: | |
name: Labels for repertoire changes | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout merged UnicodeData.txt | |
uses: actions/checkout@v3 | |
with: | |
path: merged | |
sparse-checkout: unicodetools/data/ucd/dev/UnicodeData.txt | |
- name: Checkout base UnicodeData.txt | |
uses: actions/checkout@v3 | |
with: | |
ref: ${{ github.event.pull_request.base.sha }} | |
path: base | |
sparse-checkout: unicodetools/data/ucd/dev/UnicodeData.txt | |
- name: Compare repertoire | |
id: compare-repertoire | |
run: | | |
sed 's/^\([^;]*;[^;]*\);.*$/\1/' merged/unicodetools/data/ucd/dev/UnicodeData.txt > merged-repertoire.txt | |
sed 's/^\([^;]*;[^;]*\);.*$/\1/' base/unicodetools/data/ucd/dev/UnicodeData.txt > base-repertoire.txt | |
if diff base-repertoire.txt merged-repertoire.txt | |
then echo "changed=false" >> "$GITHUB_OUTPUT" | |
else echo "changed=true" >> "$GITHUB_OUTPUT" | |
fi | |
- name: Check pipeline labels | |
if: steps.compare-repertoire.outputs.changed == 'true' | |
run: | | |
python3 <<EOF | |
import os, json | |
with open(os.environ['GITHUB_EVENT_PATH'], 'r') as f: | |
event = json.load(f) | |
print(event) | |
labels = event['pull_request']['labels'] | |
pipeline_labels = [label for label in labels if label['name'].startswith('pipeline-')] | |
if not pipeline_labels: | |
print("::error title=Missing pipeline label::PRs for character additions must have a pipeline label.") | |
exit(1) | |
if len(pipeline_labels) > 1 | |
print("::error title=Multiple pipeline labels::Only one pipeline-* label must be applied.") | |
exit(1) | |
label = pipeline_labels[0]: | |
print("Labeled", label) | |
with open(os.environ['GITHUB_OUTPUT'], 'w') as f: | |
print("pipeline-label=" + label['name'], file=f) | |
exit(0) | |
EOF | |
draft-unless-approved: | |
needs: labels-for-repertoire-changes | |
if: needs.labels-for-repertoire-changes.outputs.pipeline-label != 'pipeline-16.0' | |
name: Draft unless approved | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check draft status | |
env: | |
PIPELINE_LABEL: ${{needs.labels-for-repertoire-changes.outputs.pipeline-label}} | |
run: | | |
python3 <<EOF | |
import os, json | |
with open(os.environ['GITHUB_EVENT_PATH'], 'r') as f: | |
event = json.load(f) | |
print(event) | |
draft = event['pull_request']['draft'] | |
if not draft: | |
print("::error title=PR must be draft::PRs for character additions must be draft unless approved for the upcoming version of Unicode.") | |
exit(1) | |
EOF | |