Last active
October 5, 2022 17:05
-
-
Save mizner/01951cca14dd43e30749b70771ecc8db to your computer and use it in GitHub Desktop.
Example of Github Action WP Engine Deployment
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Deploy! | |
on: | |
push: | |
branches: | |
- production | |
- release/* | |
- feature/* | |
- bug/* | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Echo branch name | |
run: | | |
echo $GITHUB_REF | |
- name: Sync project files | |
uses: actions/checkout@v2 # https://github.com/marketplace/actions/checkout | |
- name: Setup SSH agent | |
uses: webfactory/[email protected] # https://github.com/marketplace/actions/webfactory-ssh-agent | |
with: | |
ssh-private-key: ${{ secrets.WPE_PRIVATE_KEY }} | |
- name: Add host key | |
run: | | |
ssh-keyscan -t rsa git.wpengine.com >> ~/.ssh/known_hosts | |
- name: Setup WP CLI | |
run: | | |
cd .. && mkdir wp && cd wp | |
curl -O https://raw.githubusercontent.com/wp-cli/builds/gh-pages/phar/wp-cli.phar | |
chmod +x wp-cli.phar | |
sudo mv wp-cli.phar /usr/local/bin/wp | |
- name: Setup PHP w/ Composer # https://github.com/marketplace/actions/setup-php-action | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "7.4" | |
tools: composer:v2 | |
extensions: zip | |
- name: Setup Node.js environment # https://github.com/marketplace/actions/setup-node-js-environment | |
uses: actions/[email protected] | |
# - name: Setup Yarn # https://github.com/marketplace/actions/setup-php-action | |
# uses: bahmutov/npm-install@v1 | |
- name: Install Composer Packages | |
run: | | |
composer install --no-dev --optimize-autoloader | |
- name: Install Node Modules | |
run: | | |
npm install | |
npm run build | |
- name: Filesystem CLeanup | |
run: | | |
rm -rf $(cat .clean) | |
find . -name 'node_modules' -type d -prune -exec rm -rf '{}' + | |
find . -name '.vscode' -type d -prune -exec rm -rf '{}' + | |
- name: Run git commands | |
run: | | |
find . -name ".gitignore" -exec rm -f {} \; | |
git config --global user.email "[email protected]" | |
git config --global user.name "Pyxl Engineering" | |
git add . | |
git commit -m "commit before deploy" | |
git fetch --unshallow | |
- name: Push to Prod | |
if: endsWith(github.ref, 'production') | |
run: git push -f ${{ secrets.WPE_PROD }} | |
- name: Push to Staging | |
if: startsWith(github.ref, 'refs/heads/release') | |
run: git push -f ${{ secrets.WPE_STAGE }} | |
- name: Push Bug Branch to Development | |
if: startsWith(github.ref, 'refs/heads/bug') | |
run: git push -f ${{ secrets.WPE_DEV }} | |
- name: Push Feature Branch to Development | |
if: startsWith(github.ref, 'refs/heads/feature') | |
run: git push -f ${{ secrets.WPE_DEV }} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment