Auto Deploy
Deploy your WordPressify theme automatically with GitHub Actions whenever you push to main.
Setup
1
Create a GitHub repository
Push your WordPressify project to a new GitHub repository.
2
Add secrets and variables
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).
3
Create the workflow file
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.jsonImportant 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.