Deploy your WordPressify theme automatically with GitHub Actions whenever you push to main.
Push your WordPressify project to a new GitHub repository.
In your repository, go to Settings > Secrets and variables > Actions:
THEME_NAME with your theme directory name (e.g., my-theme).Create .github/workflows/deploy.yml in your repository and paste one of the configurations below.
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:
THEME_NAME as a repository variable (not a secret). This is the name of your WordPress theme directory..env file to the repository if it contains sensitive values. Use GitHub secrets and variables instead.server-dir (FTP) or rsync destination path matches your server's WordPress installation directory.src/plugins/ (even an empty .gitkeep). An empty directory will cause the build to fail.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.