Skip to content

Commit b31346d

Browse files
committed
add BUILD_DIR flag
1 parent d515ea0 commit b31346d

File tree

2 files changed

+54
-40
lines changed

2 files changed

+54
-40
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@ This Action commits the contents of your Git tag to the WordPress.org plugin rep
2222
* `SLUG` - defaults to the repository name, customizable in case your WordPress repository has a different slug or is capitalized differently.
2323
* `VERSION` - defaults to the tag name; do not recommend setting this except for testing purposes.
2424
* `ASSETS_DIR` - defaults to `.wordpress-org`, customizable for other locations of WordPress.org plugin repository-specific assets that belong in the top-level `assets` directory (the one on the same level as `trunk`).
25+
* `BUILD_DIR` - defaults to `false`. Set this flag to the directory where you build your plugins files into, then the action will copy and deploy files from that directory. Both absolute and relative paths are supported. The relative path if provided will be concatenated with the repository root directory. All files and folders in the build directory will be deployed, `.disignore` or `.gitattributes` will be ignored.
2526

2627
### Inputs
2728
* `generate-zip` - Generate a ZIP file from the SVN `trunk` directory. Outputs a `zip-path` variable for use in further workflow steps. Defaults to false.

deploy.sh

+53-40
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,13 @@ if [[ -z "$ASSETS_DIR" ]]; then
3838
fi
3939
echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR"
4040

41+
if [[ -z "$BUILD_DIR" ]]; then
42+
BUILD_DIR=false
43+
elif [[ $BUILD_DIR != /* ]]; then
44+
BUILD_DIR="${GITHUB_WORKSPACE}/${BUILD_DIR}"
45+
fi
46+
echo "ℹ︎ BUILD_DIR is $BUILD_DIR"
47+
4148
SVN_URL="https://plugins.svn.wordpress.org/${SLUG}/"
4249
SVN_DIR="${HOME}/svn-${SLUG}"
4350

@@ -49,47 +56,53 @@ cd "$SVN_DIR"
4956
svn update --set-depth infinity assets
5057
svn update --set-depth infinity trunk
5158

52-
echo "➤ Copying files..."
53-
if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
54-
echo "ℹ︎ Using .distignore"
55-
# Copy from current branch to /trunk, excluding dotorg assets
56-
# The --delete flag will delete anything in destination that no longer exists in source
57-
rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded
58-
else
59-
echo "ℹ︎ Using .gitattributes"
60-
61-
cd "$GITHUB_WORKSPACE"
62-
63-
# "Export" a cleaned copy to a temp directory
64-
TMP_DIR="${HOME}/archivetmp"
65-
mkdir "$TMP_DIR"
66-
67-
git config --global user.email "[email protected]"
68-
git config --global user.name "10upbot on GitHub"
69-
70-
# If there's no .gitattributes file, write a default one into place
71-
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
72-
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
73-
/$ASSETS_DIR export-ignore
74-
/.gitattributes export-ignore
75-
/.gitignore export-ignore
76-
/.github export-ignore
77-
EOL
78-
79-
# Ensure we are in the $GITHUB_WORKSPACE directory, just in case
80-
# The .gitattributes file has to be committed to be used
81-
# Just don't push it to the origin repo :)
82-
git add .gitattributes && git commit -m "Add .gitattributes file"
83-
fi
84-
85-
# This will exclude everything in the .gitattributes file with the export-ignore flag
86-
git archive HEAD | tar x --directory="$TMP_DIR"
87-
88-
cd "$SVN_DIR"
8959

90-
# Copy from clean copy to /trunk, excluding dotorg assets
91-
# The --delete flag will delete anything in destination that no longer exists in source
92-
rsync -rc "$TMP_DIR/" trunk/ --delete --delete-excluded
60+
if [[ "$BUILD_DIR" = false ]]; then
61+
echo "➤ Copying files..."
62+
if [[ -e "$GITHUB_WORKSPACE/.distignore" ]]; then
63+
echo "ℹ︎ Using .distignore"
64+
# Copy from current branch to /trunk, excluding dotorg assets
65+
# The --delete flag will delete anything in destination that no longer exists in source
66+
rsync -rc --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete --delete-excluded
67+
else
68+
echo "ℹ︎ Using .gitattributes"
69+
70+
cd "$GITHUB_WORKSPACE"
71+
72+
# "Export" a cleaned copy to a temp directory
73+
TMP_DIR="${HOME}/archivetmp"
74+
mkdir "$TMP_DIR"
75+
76+
git config --global user.email "[email protected]"
77+
git config --global user.name "10upbot on GitHub"
78+
79+
# If there's no .gitattributes file, write a default one into place
80+
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
81+
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
82+
/$ASSETS_DIR export-ignore
83+
/.gitattributes export-ignore
84+
/.gitignore export-ignore
85+
/.github export-ignore
86+
EOL
87+
88+
# Ensure we are in the $GITHUB_WORKSPACE directory, just in case
89+
# The .gitattributes file has to be committed to be used
90+
# Just don't push it to the origin repo :)
91+
git add .gitattributes && git commit -m "Add .gitattributes file"
92+
fi
93+
94+
# This will exclude everything in the .gitattributes file with the export-ignore flag
95+
git archive HEAD | tar x --directory="$TMP_DIR"
96+
97+
cd "$SVN_DIR"
98+
99+
# Copy from clean copy to /trunk, excluding dotorg assets
100+
# The --delete flag will delete anything in destination that no longer exists in source
101+
rsync -rc "$TMP_DIR/" trunk/ --delete --delete-excluded
102+
fi
103+
else
104+
echo "ℹ︎ Copying files from build directory..."
105+
rsync -rc "$BUILD_DIR" trunk/ --delete --delete-excluded
93106
fi
94107

95108
# Copy dotorg assets to /assets

0 commit comments

Comments
 (0)