Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 49 additions & 33 deletions dotorg-plugin-deploy/entrypoint.sh
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,9 @@ if [[ -z "$SVN_PASSWORD" ]]; then
fi

if [[ -z "$GITHUB_TOKEN" ]]; then
echo "Set the GITHUB_TOKEN env variable"
exit 1
echo "ℹ︎ Deploying current working files"
else
echo "ℹ︎ Deploying files from git archive"
fi

# Allow some ENV variables to be customized
Expand Down Expand Up @@ -54,39 +55,54 @@ svn update --set-depth infinity assets
svn update --set-depth infinity trunk

echo "➤ Copying files..."
cd "$GITHUB_WORKSPACE"

# "Export" a cleaned copy to a temp directory
TMP_DIR="/github/archivetmp"
mkdir "$TMP_DIR"

git config --global user.email "10upbot+github@10up.com"
git config --global user.name "10upbot on GitHub"

# If there's no .gitattributes file, write a default one into place
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
/$ASSETS_DIR export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
EOL

# Ensure we are in the $GITHUB_WORKSPACE directory, just in case
# The .gitattributes file has to be committed to be used
# Just don't push it to the origin repo :)
git add .gitattributes && git commit -m "Add .gitattributes file"
if [[ -z "$GITHUB_TOKEN" ]]; then
# If there's no .distignore file, write a default one into place
if [[ ! -e "$GITHUB_WORKSPACE/.distignore" ]]; then
cat > "$GITHUB_WORKSPACE/.distignore" <<-EOL
/$ASSETS_DIR
/.git*
/.distignore
EOL
fi

# Copy from current branch to /trunk, excluding dotorg assets
# The --delete flag will delete anything in destination that no longer exists in source
rsync -r --exclude-from="$GITHUB_WORKSPACE/.distignore" "$GITHUB_WORKSPACE/" trunk/ --delete
else
cd "$GITHUB_WORKSPACE"

# "Export" a cleaned copy to a temp directory
TMP_DIR="/github/archivetmp"
mkdir "$TMP_DIR"

git config --global user.email "10upbot+github@10up.com"
git config --global user.name "10upbot on GitHub"

# If there's no .gitattributes file, write a default one into place
if [[ ! -e "$GITHUB_WORKSPACE/.gitattributes" ]]; then
cat > "$GITHUB_WORKSPACE/.gitattributes" <<-EOL
/$ASSETS_DIR export-ignore
/.gitattributes export-ignore
/.gitignore export-ignore
/.github export-ignore
EOL

# Ensure we are in the $GITHUB_WORKSPACE directory, just in case
# The .gitattributes file has to be committed to be used
# Just don't push it to the origin repo :)
git add .gitattributes && git commit -m "Add .gitattributes file"
fi

# This will exclude everything in the .gitattributes file with the export-ignore flag
git archive HEAD | tar x --directory="$TMP_DIR"

cd "$SVN_DIR"

# Copy from clean copy to /trunk, excluding dotorg assets
# The --delete flag will delete anything in destination that no longer exists in source
rsync -rc "$TMP_DIR/" trunk/ --delete
fi

# This will exclude everything in the .gitattributes file with the export-ignore flag
git archive HEAD | tar x --directory="$TMP_DIR"

cd "$SVN_DIR"

# Copy from clean copy to /trunk, excluding dotorg assets
# The --delete flag will delete anything in destination that no longer exists in source
rsync -rc "$TMP_DIR/" trunk/ --delete

# Copy dotorg assets to /assets
rsync -rc "$GITHUB_WORKSPACE/$ASSETS_DIR/" assets/ --delete

Expand Down