-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #52 from wpengine/automated-deployment
[COE-1640] Add automated deployment mechanism
- Loading branch information
Showing
10 changed files
with
130 additions
and
1 deletion.
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
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
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,13 @@ | ||
# Attribution: Helen Hou-Sandi https://github.com/10up/action-wordpress-plugin-deploy/ | ||
FROM debian:stable-slim | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y subversion rsync git \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* \ | ||
&& git config --global user.email "[email protected]" \ | ||
&& git config --global user.name "[email protected]" | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] | ||
WORKDIR /workspace |
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,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2019 Helen Hou-Sandi | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
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,86 @@ | ||
#!/bin/bash | ||
|
||
# Note that this does not use pipefail | ||
# because if the grep later doesn't match any deleted files, | ||
# which is likely the majority case, | ||
# it does not exit with a 0, and I only care about the final exit. | ||
set -eo | ||
|
||
WORKDIR="/workspace" | ||
|
||
# Ensure SVN username and password are set | ||
# IMPORTANT: while secrets are encrypted and not viewable in the GitHub UI, | ||
# they are by necessity provided as plaintext in the context of the Action, | ||
# so do not echo or use debug mode unless you want your secrets exposed! | ||
if [[ -z "$SVN_USERNAME" ]]; then | ||
echo "Set the SVN_USERNAME secret" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$SVN_PASSWORD" ]]; then | ||
echo "Set the SVN_PASSWORD secret" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$SLUG" ]]; then | ||
echo "Set the SLUG" | ||
exit 1 | ||
fi | ||
|
||
if [[ -z "$VERSION" ]]; then | ||
echo "Set the VERSION" | ||
exit 1 | ||
fi | ||
|
||
echo "ℹ︎ SLUG is $SLUG" | ||
echo "ℹ︎ VERSION is $VERSION" | ||
|
||
if [[ -z "$ASSETS_DIR" ]]; then | ||
ASSETS_DIR="wordpress-org-assets" | ||
fi | ||
echo "ℹ︎ ASSETS_DIR is $ASSETS_DIR" | ||
|
||
SVN_URL="http://plugins.svn.wordpress.org/${SLUG}/" | ||
SVN_DIR="/tmp/svn-${SLUG}" | ||
|
||
# Checkout just trunk and assets for efficiency | ||
# Tagging will be handled on the SVN level | ||
echo "➤ Checking out .org repository..." | ||
svn checkout --depth immediates "$SVN_URL" "$SVN_DIR" | ||
cd "$SVN_DIR" | ||
svn update --set-depth infinity assets | ||
svn update --set-depth infinity trunk | ||
|
||
echo "➤ Copying files..." | ||
BUILD_SRC="$WORKDIR/src" | ||
# Copy from current branch to /trunk, excluding dotorg assets | ||
# The --delete flag will delete anything in destination that no longer exists in source | ||
rsync -rc "$BUILD_SRC/" trunk/ --delete | ||
|
||
# Copy dotorg assets to /assets | ||
rsync -rc "$WORKDIR/$ASSETS_DIR/" assets/ --delete | ||
|
||
# Add everything and commit to SVN | ||
# The force flag ensures we recurse into subdirectories even if they are already added | ||
# Suppress stdout in favor of svn status later for readability | ||
echo "➤ Preparing files..." | ||
svn add . --force > /dev/null | ||
|
||
# SVN delete all deleted files | ||
# Also suppress stdout here | ||
svn status | grep '^\!' | sed 's/! *//' | xargs -I% svn rm % > /dev/null | ||
|
||
# Copy tag locally to make this a single commit | ||
echo "➤ Copying tag..." | ||
svn cp "trunk" "tags/$VERSION" | ||
|
||
svn status | ||
|
||
if [[ -z "$DEPLOY" ]]; then | ||
echo "Set DEPLOY to deploy to SVN" | ||
exit 1 | ||
fi | ||
|
||
echo "➤ Committing files..." | ||
svn commit -m "Update to version $VERSION from TravisCI" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
echo "✓ Plugin deployed!" |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.