Skip to content

update workflow

update workflow #2

Workflow file for this run

name: Deploy to WordPress SVN
on:
push:
tags:
- 'v*.*.*'
jobs:
deploy:
runs-on: ubuntu-latest
steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v2
# Step 2: Set up Node.js (use the latest stable version)
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 'lts/*' # Use latest LTS version of Node.js
# Step 3: Generate readme.txt using the Node.js script
- name: Generate readme.txt
run: node .github/scripts/generate-readme.js
# Step 4: Install Subversion
- name: Install Subversion
run: sudo apt-get install subversion
# Step 5: Check for Active Processes and Deploy to WordPress SVN /trunk/
- name: Deploy to WordPress SVN /trunk/
env:
SVN_USERNAME: ${{ secrets.WORDPRESS_USERNAME }}
SVN_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
run: |
# Create a lock file to prevent simultaneous modifications
LOCKFILE="/tmp/rsync.lock"
if [ -f "$LOCKFILE" ]; then
echo "Lock file exists. Another process might be running."
exit 1
fi
# Create the lock file
touch "$LOCKFILE"
# Check for active processes that might modify the source directory
if lsof +D ./ | grep -q .; then
echo "There are active processes modifying the source directory."
rm -f "$LOCKFILE" # Remove the lock file before exiting
exit 1
fi
# Retry mechanism for rsync
MAX_RETRIES=5
COUNT=0
until [ "$COUNT" -ge "$MAX_RETRIES" ]
do
rsync -av --delete --exclude=".git" ./ svn-dir/trunk/ && break
COUNT=$((COUNT+1))
echo "rsync failed. Attempt $COUNT/$MAX_RETRIES..."
sleep 5 # Wait before retrying
done
if [ "$COUNT" -eq "$MAX_RETRIES" ]; then
echo "rsync failed after $MAX_RETRIES attempts."
rm -f "$LOCKFILE" # Remove the lock file before exiting
exit 1
fi
# Copy the newly generated readme.txt
cp .github/temp/readme.txt svn-dir/trunk/readme.txt
# Commit changes to SVN
cd svn-dir
svn add --force trunk/*
svn commit -m "Deploying version ${{ github.ref }}" --username $SVN_USERNAME --password $SVN_PASSWORD --non-interactive
# Remove the lock file after everything is done
rm -f "$LOCKFILE"
# Step 6: Create a tag in WordPress SVN /tags/
- name: Create SVN Tag
env:
SVN_USERNAME: ${{ secrets.WORDPRESS_USERNAME }}
SVN_PASSWORD: ${{ secrets.WORDPRESS_PASSWORD }}
run: |
VERSION=${GITHUB_REF/refs\/tags\/v/}
svn cp https://plugins.svn.wordpress.org/discontinued-products/trunk https://plugins.svn.wordpress.org/discontinued-products/tags/$VERSION -m "Tagging version $VERSION" --username $SVN_USERNAME --password $SVN_PASSWORD --non-interactive