Skip to content

Commit

Permalink
set up staging deploy
Browse files Browse the repository at this point in the history
  • Loading branch information
FredericoAndrade committed Jul 19, 2024
1 parent c36fe80 commit a11cf08
Show file tree
Hide file tree
Showing 3 changed files with 53 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Deploy to GreenGeeks
name: Deploy to Production

on:
push:
Expand Down
34 changes: 34 additions & 0 deletions .github/workflows/deploy-staging.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: Deploy to Staging

on:
push:
branches:
- staging

env:
REMOTE_DIR: ./public_html/staging/wp-content/themes/blankslate-child

jobs:
deploy:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Install rsync
run: sudo apt-get install -y rsync

- name: Setup SSH
uses: webfactory/[email protected]
with:
ssh-private-key: ${{ secrets.SSH_PRIVATE_KEY }}

- name: Add server to known hosts
run: ssh-keyscan -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts

- name: Deploy via rsync
run: rsync -avz --delete -e "ssh -o StrictHostKeyChecking=no" . ${{ secrets.SSH_USERNAME }}@${{ secrets.SSH_HOST }}:${{ env.REMOTE_DIR }}

- name: Clean up known hosts
run: rm -f ~/.ssh/known_hosts
18 changes: 18 additions & 0 deletions functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -196,6 +196,24 @@ function wt_mobile_menu() {

add_action( 'init', 'wt_mobile_menu' );

function get_environment() {
if (strpos($_SERVER['HTTP_HOST'], 'localhost') !== false) {
return 'localhost';
} elseif (strpos($_SERVER['HTTP_HOST'], 'staging') !== false) {
return 'staging';
} else {
return '';
}
}

function modify_page_title() {
$environment = get_environment();
if ($environment) {
echo "<script>document.title = '" . ucfirst($environment) . " | ' + document.title;</script>";
}
}
add_action('wp_head', 'modify_page_title');

// Pagination for paged posts, Page 1, Page 2, Page 3, with Next and Previous Links, No plugin
function html5wp_pagination()
{
Expand Down

0 comments on commit a11cf08

Please sign in to comment.