-
Notifications
You must be signed in to change notification settings - Fork 15
42 lines (35 loc) · 1.22 KB
/
validate-directory-and-prefix.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
# We need the directory of the ceremony to match the prefix of the ceremony.
name: Validate Directory name and prefix
on:
pull_request:
paths:
- 'ceremonies/**'
jobs:
verify:
runs-on: ubuntu-latest
if: endsWith(github.head_ref, '-ceremony')
steps:
- uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: '16'
- name: Install jq
run: sudo apt-get install jq -y
- name: Read JSON and get title
run: |
title=$(jq -r '.title' ./ceremonies/$(echo $GITHUB_HEAD_REF | tr '[:upper:]' '[:lower:]')/p0tionConfig.json)
echo "Title: $title"
echo "TITLE=$title" >> $GITHUB_ENV
- name: Transform and compare
run: |
prefix=$(echo "${TITLE}" | tr '[:upper:]' '[:lower:]' | tr ' ' '-' | tr -dc '[:alnum:]-\n\r')
echo "Converted Prefix: $prefix"
DIR_NAME="$(echo $GITHUB_HEAD_REF | tr '[:upper:]' '[:lower:]')"
echo "Dir name: $DIR_NAME"
if [ "$prefix" != $DIR_NAME ]; then
echo "Error: The ceremony artifacts directory name and ceremony prefix do not match!"
exit 1
else
echo "Directory name and ceremony prefix match."
fi