-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Add main.workflow Add `workflow` file for plugin deploy to wordpress.org repository. * Add custom action Add custom action for plugin deploy from the src folder * Update main.workflow * Update main.workflow * Add secrets
- Loading branch information
1 parent
6736c82
commit 7a62b2a
Showing
3 changed files
with
102 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,14 @@ | ||
FROM debian:stable-slim | ||
|
||
LABEL "com.github.actions.name"="Deploy Plugin" | ||
LABEL "com.github.actions.description"="Deploy to the WordPress Plugin Repository" | ||
LABEL "com.github.actions.icon"="upload-cloud" | ||
LABEL "com.github.actions.color"="red" | ||
|
||
RUN apt-get update \ | ||
&& apt-get install -y subversion rsync \ | ||
&& apt-get clean -y \ | ||
&& rm -rf /var/lib/apt/lists/* | ||
|
||
COPY entrypoint.sh /entrypoint.sh | ||
ENTRYPOINT ["/entrypoint.sh"] |
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,69 @@ | ||
#!/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 | ||
|
||
# Ensure SVN username and password are set | ||
# IMPORTANT: secrets are accessible by anyone with write access to the repository! | ||
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 | ||
|
||
# Allow some ENV variables to be customized | ||
if [[ -z "$SLUG" ]]; then | ||
SLUG=${GITHUB_REPOSITORY#*/} | ||
fi | ||
echo "ℹ︎ SLUG is $SLUG" | ||
|
||
# Does it even make sense for VERSION to be editable in a workflow definition? | ||
if [[ -z "$VERSION" ]]; then | ||
VERSION=${GITHUB_REF#refs/tags/} | ||
fi | ||
echo "ℹ︎ VERSION is $VERSION" | ||
|
||
SVN_URL="http://plugins.svn.wordpress.org/${SLUG}/" | ||
SVN_DIR="/github/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..." | ||
|
||
# Copy from the `src folder of the`current branch to /trunk | ||
# The --delete flag will delete anything in destination that no longer exists in source | ||
rsync -r "$GITHUB_WORKSPACE/src/" trunk/ --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 | ||
|
||
svn status | ||
|
||
echo "︎➤ Committing files..." | ||
svn commit -m "Update to version $VERSION from GitHub" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
|
||
# SVN tag to VERSION | ||
echo "➤ Tagging version..." | ||
svn cp "^/$SLUG/trunk" "^/$SLUG/tags/$VERSION" -m "Tag $VERSION" --no-auth-cache --non-interactive --username "$SVN_USERNAME" --password "$SVN_PASSWORD" | ||
|
||
echo "✓ Plugin deployed!" |
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,19 @@ | ||
workflow "Deploy" { | ||
resolves = ["Deploy Plugin"] | ||
on = "push" | ||
} | ||
|
||
# Filter for tag | ||
action "tag" { | ||
uses = "actions/bin/filter@master" | ||
args = "tag" | ||
} | ||
|
||
action "Deploy Plugin" { | ||
needs = ["tag"] | ||
uses = "./.github/deploy-plugin" | ||
env = { | ||
SLUG = "spiderblocker" | ||
} | ||
secrets = ["SVN_USERNAME", "SVN_PASSWORD"] | ||
} |