Skip to content

Commit 777e119

Browse files
author
user
committed
Deduplicate locked down files list
Remove the list of locked down files from locked_down_files.txt and instead use the .github workflow as a single source of truth. This requires some complicated parsing in the verification script as well as a dependency from the verification script to the workflow YAML. These are not ideal design choices however the alternative is to not have a single source of truth for the locked down files as the github workflow can not depend on an external file.
1 parent ecf331a commit 777e119

File tree

3 files changed

+12
-8
lines changed

3 files changed

+12
-8
lines changed

.github/workflows/verify-locked-down-signatures.yml

+2
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,8 @@ on:
55
- .github/workflows/verify-locked-down-signatures.yml
66
- Cargo.lock
77
- gui/package-lock.json
8+
- ci/keys/
9+
- ci/verify-locked-down-signatures.sh
810
workflow_dispatch:
911
jobs:
1012
verify-signatures:

ci/locked_down_files.txt

-6
This file was deleted.

ci/verify-locked-down-signatures.sh

+10-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,17 @@ if [[ "$import_gpg_keys" == "true" ]]; then
3838
done
3939
fi
4040

41+
# Parse the locked down files from the github actions workflow file.
42+
# We need to define them there since github has no way to trigger on filepaths specified in a file.
43+
# We parse them from there in order to avoid duplicating the locked down files in multiple places.
44+
#
45+
# This regexp line is using a regexp to parse the github .yml file for the YAML list that follows the `paths` key.
46+
# It uses `tr` in order to turn the multi-lined file into a single-line that sed can parse correctly. This is done by replacing all new-lines with a `;`
47+
SEPARATOR=';'
48+
locked_down_files=$(cat $SCRIPT_DIR/../.github/workflows/verify-locked-down-signatures.yml | tr '\n' $SEPARATOR | sed "s/.*paths:$SEPARATOR\(\(\s*-\s[a-zA-Z\/\.-]*$SEPARATOR\)*\).*/\1/" | tr $SEPARATOR '\n' | awk '{print $2}')
49+
4150
unsigned_commits_exist=0
42-
LOCKED_DOWN_FILES=$(cat $SCRIPT_DIR/locked_down_files.txt)
43-
for locked_file in $LOCKED_DOWN_FILES; do
51+
for locked_file in $locked_down_files; do
4452
locked_file_commit_hashes=$(git rev-list --oneline $whitelisted_commit..HEAD $SCRIPT_DIR/../$locked_file | awk '{print $1}')
4553
for commit in $locked_file_commit_hashes;
4654
do

0 commit comments

Comments
 (0)