Last active
October 4, 2022 00:25
-
-
Save andriilive/3bf959ce12e758715bd96e5e77df99eb to your computer and use it in GitHub Desktop.
Build WP roots/bedrock with roots/sage theme & Deploy via SSH
This file contains 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
# https://gist.github.com/andriilive/3bf959ce12e758715bd96e5e77df99eb | |
name: Staging | Build & Deploy WP (Bedrock & WP-CLI) | |
on: | |
push: | |
branches: [ envs/staging ] | |
pull_request: | |
branches: [ envs/staging ] | |
jobs: | |
build_and_deploy: | |
name: Build theme with Node 16 & PHP 8.0 | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout the project | |
uses: actions/checkout@v3 | |
- name: Setup the Node env | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 16 | |
- name: Restore the Yarn cache directory | |
id: yarncache | |
run: echo "::set-output name=dir::$(yarn cache dir)" | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.yarncache.outputs.dir }} | |
key: ${{ runner.os }}-16-yarn-${{ hashFiles('**/yarn.lock') }} | |
restore-keys: ${{ runner.os }}-16-yarn- | |
- name: Install dependencies using Yarn | |
run: yarn --cwd ./web/app/themes/theme install | |
- name : Build theme | |
run: yarn --cwd ./web/app/themes/theme build | |
- name: Setup the PHP environment with wp-cli | |
uses: shivammathur/setup-php@v2 | |
with: | |
php-version: '8.0' | |
tools: wp | |
- name: Restore the Composer cache directory | |
id: composercache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- uses: actions/cache@v3 | |
with: | |
path: ${{ steps.composercache.outputs.dir }} | |
key: ${{ runner.os }}-'8.0'-composer-${{ hashFiles('**/composer.json') }} | |
restore-keys: ${{ runner.os }}-'8.0'-composer- | |
- name: Install Composer dependencies | |
run: composer install --no-progress --no-dev --prefer-dist --optimize-autoloader --no-suggest | |
- name: Copy staging contents | |
run: php -r "copy('config/envs/staging/.env', '.env');" | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Adding Known Hosts | |
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> /home/runner/.ssh/known_hosts | |
- name: Deploy with rsync | |
run: rsync -avz ./ ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:public_html --exclude-from='.distignore' | |
- name: Continue install on a Server | |
run: ssh ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }} 'cd public_html && wp cache flush' |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment