@@ -36,7 +36,7 @@ PROJECT_ID="$INPUT_PROJECT_ID"
36
36
GITHUB_ACCESS_TOKEN="$INPUT_GH_PERSONAL_ACCESS_TOKEN "
37
37
OUT
38
38
39
- initGitRepoForTargetDir () {
39
+ initTargetDirGitRepo () {
40
40
rsync -avq " $sourceDirPath /.git" " $targetDirPath "
41
41
42
42
pushd " $targetDirPath " > /dev/null
@@ -68,29 +68,43 @@ copyFilesFromSourceDirToTargetDir() {
68
68
# --exclude=node_modules/ \
69
69
}
70
70
71
- # $dirPath: Directory path with composer.json file.
72
71
initComposerPackages () {
73
72
pushd " $1 " > /dev/null
74
73
composer update --no-dev --no-interaction
75
74
composer dump-autoload --classmap-authoritative --no-interaction
76
75
popd > /dev/null
77
76
}
78
77
79
- initGitRepoForTargetDir
78
+ prepareTheTargetDir () {
79
+ pushd " $targetDirPath " > /dev/null
80
+
81
+ # Remove the source composer.json, composer.lock, vendor, and vendor_prefixed to avoid collisions when receiving the prefixed results
82
+ find " $targetDirPath " \( \( -name composer.json -o -name composer.lock \) -type f \) -print0 | xargs -0 rm -rf
83
+ find " $targetDirPath " \( \( -name vendor -o -name vendor_prefixed \) -type d \) -print0 | xargs -0 rm -rf
84
+ }
85
+
86
+ # Create the target directory where the prefixed results will be stored
87
+ initTargetDirGitRepo
88
+
89
+ # Composer update & dump-autoload to check everything is Ok
80
90
initComposerPackages " $sourceDirPath "
91
+
92
+ # Copy everything from source to target to have the complete project on the target directory
81
93
copyFilesFromSourceDirToTargetDir
82
- initComposerPackages " $targetDirPath "
83
94
84
- pushd " $targetDirPath " > /dev/null
95
+ # Composer update & dump-autoload to check everything is Ok
96
+ initComposerPackages " $targetDirPath "
85
97
86
- find " $targetDirPath " \( \( -name composer.json -o -name composer.lock \) -type f \) -print0 | xargs -0 rm -rf
87
- find " $targetDirPath " \( \( -name vendor -o -name vendor_prefixed \) -type d \) -print0 | xargs -0 rm -rf
98
+ # Clean the composer-related files from target directory before prefixing
99
+ prepareTheTargetDir
88
100
101
+ # Let's go!
89
102
/php-prefixer-cli.phar prefix --delete-build
90
103
91
104
CHANGED=$( git status --porcelain)
92
105
93
106
if [ -n " ${CHANGED} " ]; then
107
+ # If there're changes, commit them
94
108
git add --all .
95
109
git commit --all -m " Publish prefixed build $( date ' +%Y-%m-%d %H:%M:%S' ) "
96
110
git pull -s ours $remote " $INPUT_TARGET_BRANCH " || true # remote may not exist
0 commit comments