forked from doctrine/doctrine1
-
Notifications
You must be signed in to change notification settings - Fork 75
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add workflow to check the content of the archive
- Loading branch information
Showing
5 changed files
with
86 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
lib/ | ||
CHANGELOG.md | ||
COPYRIGHT | ||
LICENSE | ||
README.md | ||
UPGRADE_TO_1_2 | ||
composer.json |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
#!/bin/sh | ||
|
||
branch=$1 | ||
hash=$2 | ||
|
||
git fetch origin | ||
|
||
# root folder of added files | ||
git diff --color --name-only --diff-filter=A ${branch}..${hash} | cut -d/ -f1 || exit 1 | ||
|
||
# list changed root files | ||
git diff --name-only ${branch}..${hash} | grep '/' -v || exit 1 | ||
|
||
# the previous command lists the changed files as their new name, so we list the original names too | ||
git diff ${branch}..${hash} | grep '^rename from' | sed 's/^rename from //' | cut -d/ -f1 || exit 1 |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
#!/bin/sh | ||
|
||
cat - | sort | uniq | wc -l |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
#!/bin/sh | ||
|
||
archive_name=$1 | ||
pattern_file=$(dirname $0)/archive_allow.txt | ||
|
||
if [ ! -f "$pattern_file" ] | ||
then | ||
echo "config file not exists: $pattern_file" | ||
exit 1 | ||
fi | ||
|
||
# test for empty | ||
|
||
archive_content=$(tar -tf $archive_name) | ||
|
||
for pattern in $(cat $pattern_file) | ||
do | ||
archive_content=$(echo "$archive_content" | grep -v "^$pattern") | ||
done | ||
|
||
if [ $(echo "$archive_content" | grep ^$ -v | wc -l) -gt 0 ] | ||
then | ||
echo "Files not allowed in archive:" | ||
echo "$archive_content" | ||
exit 1 | ||
fi |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
name: Git Archive Content Check | ||
|
||
on: | ||
pull_request: | ||
branches: | ||
- master | ||
paths: | ||
- .github/workflows/archive-validation.yml | ||
- .ci/github/archive_allow.txt | ||
- ./* | ||
push: | ||
branches: | ||
- master | ||
paths: | ||
- .github/workflows/archive-validation.yml | ||
- .ci/github/archive_allow.txt | ||
- ./* | ||
|
||
jobs: | ||
archive-validation: | ||
name: Git Archive Content Check | ||
|
||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v4 | ||
|
||
- id: number-of-changed-files | ||
run: | | ||
echo "NO_OF_FILES_CHANGED_IN_ROOT=$(.ci/github/files_between_commits.sh origin/$GITHUB_BASE_REF $GITHUB_SHA | .ci/github/number_of_files_changed_in_root.sh)" >> $GITHUB_ENV | ||
- run: | | ||
git archive -o archive.tar $GITHUB_SHA && sh .ci/github/validate_archive.sh archive.tar | ||
if: ${{ steps.number-of-changed-files.outputs.no_of_changed_files_in_root > 0 }} | ||