Skip to content

Commit 6075a85

Browse files
authored
Add GitHub Actions workflow to verify NIC files match source (#35)
* Update iphone_preference_bundle.nic.tar to pass integrity_check.sh
1 parent 78f54b9 commit 6075a85

File tree

3 files changed

+63
-0
lines changed

3 files changed

+63
-0
lines changed

.github/workflows/nic-integrity.yml

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
name: NIC Integrity
2+
3+
on:
4+
push:
5+
6+
jobs:
7+
check:
8+
runs-on: ubuntu-latest
9+
env:
10+
THEOS: ${{ github.workspace }}/theos
11+
steps:
12+
- name: Checkout repo
13+
uses: actions/checkout@v4
14+
with:
15+
submodules: recursive
16+
path: templates
17+
18+
- name: Checkout theos/theos
19+
uses: actions/checkout@v4
20+
with:
21+
repository: theos/theos
22+
submodules: recursive
23+
path: ${{ env.THEOS }}
24+
25+
- name: Check
26+
run: |
27+
cd templates
28+
./integrity_check.sh

integrity_check.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
set -e
4+
5+
WORKSPACE_DIR=$(mktemp -d --tmpdir='' "templates.XXXXXXXXXX")
6+
TEMPLATES_DIR=$(pwd)
7+
8+
# For each directory containing a valid NIC templates' source
9+
TEMPLATES_SOURCES=$(find "${TEMPLATES_DIR}" -type d -name NIC -exec dirname {} \;)
10+
11+
cd "${WORKSPACE_DIR}"
12+
13+
EXIT_CODE=0
14+
15+
for TEMPLATES_SOURCE in $TEMPLATES_SOURCES; do
16+
"${THEOS}/bin/nicify.pl" "${TEMPLATES_SOURCE}" 2> /dev/null
17+
RESULT_FILE=$(ls *.nic.tar)
18+
EXTRACT_DIR=$(mktemp -d -p . "${RESULT_FILE}.XXXXXXXXXX")
19+
tar -xf "${TEMPLATES_DIR}/${RESULT_FILE}" -C "${EXTRACT_DIR}"
20+
# thanks to https://stackoverflow.com/a/49633090
21+
if ! diff -r --no-dereference --brief -x '.keep' "${TEMPLATES_SOURCE}" "${EXTRACT_DIR}"; then
22+
EXIT_CODE=1
23+
# per https://docs.github.com/en/actions/learn-github-actions/variables#default-environment-variables
24+
if [[ "${GITHUB_ACTIONS}" = "true" ]]; then
25+
# per https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#setting-an-error-message
26+
echo "::error file=${RESULT_FILE},title=Mismatch::The NIC file does not match the template directory"
27+
fi
28+
fi
29+
rm -r "${EXTRACT_DIR}"
30+
rm "${RESULT_FILE}"
31+
done
32+
33+
rm -r "${WORKSPACE_DIR}"
34+
35+
exit "${EXIT_CODE}"

iphone_preference_bundle.nic.tar

512 Bytes
Binary file not shown.

0 commit comments

Comments
 (0)