Skip to content

Commit 774ec7c

Browse files
committed
Revert deleted commands for deploying the plugin
1 parent 8d10f88 commit 774ec7c

1 file changed

Lines changed: 82 additions & 0 deletions

File tree

entrypoint.sh

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,85 @@ if [[ -z "$VERSION" ]]; then
3333
fi
3434
echo "ℹ︎ VERSION is $VERSION"
3535

36+
if [[ -z "$ASSETS_DIR" ]]; then
37+
ASSETS_DIR=".wordpress-org"
38+
fi
39+
echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR"
40+
41+
SVN_URL="http://plugins.svn.wordpress.org/${SLUG}/"
42+
SVN_DIR="/github/svn-${SLUG}"
43+
44+
# Checkout just trunk and assets for efficiency
45+
# Tagging will be handled on the SVN level
46+
echo "➤ Checking out .org repository..."
47+
svn checkout --depth immediates "$SVN_URL" "$SVN_DIR"
48+
cd "$SVN_DIR"
49+
svn update --set-depth infinity assets
50+
svn update --set-depth infinity trunk
51+
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
58+
else
59+
echo "ℹ︎ Using .gitattributes"
60+
61+
cd "$GITHUB_WORKSPACE"
62+
63+
# "Export" a cleaned copy to a temp directory
64+
TMP_DIR="/github/archivetmp"
65+
mkdir "$TMP_DIR"
66+
67+
git config --global user.email "10upbot+github@10up.com"
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"
89+
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
93+
fi
94+
95+
# Copy dotorg assets to /assets
96+
rsync -rc "$GITHUB_WORKSPACE/$ASSETS_DIR/" assets/ --delete
97+
98+
# Add everything and commit to SVN
99+
# The force flag ensures we recurse into subdirectories even if they are already added
100+
# Suppress stdout in favor of svn status later for readability
101+
echo "➤ Preparing files..."
102+
svn add . --force > /dev/null
103+
104+
# SVN delete all deleted files
105+
# Also suppress stdout here
106+
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null
107+
108+
# Copy tag locally to make this a single commit
109+
echo "➤ Copying tag..."
110+
svn cp "trunk" "tags/$VERSION"
111+
112+
svn status
113+
114+
echo "➤ Committing files..."
115+
svn commit -m "Update to version $VERSION from GitHub" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD"
116+
117+
echo "✓ Plugin deployed!"

0 commit comments

Comments
 (0)