Auto Deploy
Deploy your WordPressify theme automatically with GitHub Actions whenever you push to main.
Setup
Push your WordPressify project to a new GitHub repository.
In your repository, go to Settings > Secrets and variables > Actions:
- Under Variables, create
THEME_NAMEwith your theme directory name (e.g.,my-theme). - Under Secrets, add the credentials for your chosen deployment method (see below).
Create .github/workflows/deploy.yml in your repository and paste one of the configurations below.
Deployment Methods
Add these secrets to your repository: FTP_SERVER, FTP_USERNAME, FTP_PASSWORD.
name: Deploy WordPressify
on:
push:
branches:
- main
env:
THEME_NAME: ${{ vars.THEME_NAME }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
npm install
npm run build
- name: Build theme
run: |
npm run export
- name: Set permissions
run: |
sudo chown -R $USER:$USER ./dist
chmod -R 755 ./dist
mkdir -p dist/themes/${{ env.THEME_NAME }}
touch dist/themes/${{ env.THEME_NAME }}/.ftp-deploy-sync-state.json
chmod 666 dist/themes/${{ env.THEME_NAME }}/.ftp-deploy-sync-state.json
- name: Deploy to WordPress
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
local-dir: ./dist/themes/${{ env.THEME_NAME }}/
server-dir: /public_html/wp-content/themes/${{ env.THEME_NAME }}/
exclude: |
**/.git*
**/.git*/**
**/node_modules/**
**/src/**
gulpfile.js
package.json
package-lock.jsonAdd these secrets to your repository: SSH_HOST, SSH_USERNAME, SSH_KNOWN_HOSTS, SSH_PRIVATE_KEY.
name: Deploy WordPressify
on:
push:
branches:
- main
env:
THEME_NAME: ${{ vars.THEME_NAME }}
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: "20"
- name: Install dependencies
run: |
npm install
npm run build
- name: Build theme
run: |
npm run export
- name: Set permissions
run: |
sudo chown -R $USER:$USER ./dist
chmod -R 755 ./dist
mkdir -p dist/themes/${{ env.THEME_NAME }}
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ secrets.SSH_PRIVATE_KEY }}
known_hosts: ${{ secrets.SSH_KNOWN_HOSTS }}
- name: Deploy to WordPress via SSH
run: |
rsync -avz --delete \
-e "ssh -p 22" \
--exclude '.git*' \
--exclude '.git*/**' \
--exclude 'node_modules/**' \
--exclude 'src/**' \
--exclude 'gulpfile.js' \
--exclude 'package.json' \
--exclude 'package-lock.json' \
./dist/themes/${{ env.THEME_NAME }}/ \
${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:/var/www/html/wp-content/themes/${{ env.THEME_NAME }}/Important notes:
- Set
THEME_NAMEas a repository variable (not a secret). This is the name of your WordPress theme directory. - Do not commit your
.envfile to the repository if it contains sensitive values. Use GitHub secrets and variables instead. - Verify the
server-dir(FTP) or rsync destination path matches your server's WordPress installation directory. - Keep at least one file in
src/plugins/(even an empty.gitkeep). An empty directory will cause the build to fail.
Triggering the Deployment
Once the workflow file is committed and pushed to main, every subsequent push to main will automatically build and deploy your theme.
Secrets are encrypted and cannot be viewed once saved. You can update a secret at any time by creating a new one with the same name. Never commit credentials to your repository.