Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save ValeriiVasyliev/0e36a142ee808b22747d75f2842abaab to your computer and use it in GitHub Desktop.
Save ValeriiVasyliev/0e36a142ee808b22747d75f2842abaab to your computer and use it in GitHub Desktop.
Deploy to Kinsta Github Actions Bedrock/Sage9
#Go in your kinsta serv with ssh in terminal and make this two steps :
#1: cat ~/.ssh/id_rsa.pub and copy paste in user setting in kinsta and SSH KEY
#2: cat ~/.ssh/id_rsa and copy paste in secret SSH_KEY
name: Deploy to Kinsta
on:
push:
branches: [ main ]
jobs:
deploy:
runs-on: ubuntu-latest
env:
ACF_PRO_KEY: ${{ secrets.ACF_PRO_KEY }} #exemple for premium plugins
SSH_PORT: ${{ secrets.PORT }} #1547
SSH_HOST: ${{ secrets.HOST }} #0.0.0.0
SSH_KEY: ${{ secrets.SSH_KEY }}
KNOWN_HOSTS: ${{ secrets.KNOWN_HOSTS }} #0.0.0.0:1547
SSH_USERNAME: ${{ secrets.USERNAME }} #username
KINSTA_FOLDER: ${{ secrets.REMOTE_DIR }} #/var/www/public
DOMAIN: ${{ secrets.DOMAIN_STAGING }} #url.com
THEME: 'themename'
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: '14'
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '7.4'
- name: Install SSH key
uses: shimataro/ssh-key-action@v2
with:
key: ${{ env.SSH_KEY }}
name: id_rsa # optional
known_hosts: ${{ env.KNOWN_HOSTS }}
if_key_exists: fail # replace / ignore / fail; optional (defaults to fail)
- name: Cache Composer packages
id: composer-cache
uses: actions/cache@v2
with:
path: vendor
key: ${{ runner.os }}-php-${{ hashFiles('**/composer.lock') }}
restore-keys: |
${{ runner.os }}-php-
- name: Update Composer Bedrock
run: composer update --prefer-dist --no-progress --no-dev
# build sage based theme (remove if not used)
- name: Update Composer Sage
run: cd web/app/themes/${{ env.THEME }} && composer update --prefer-dist --no-progress --no-dev
- name: Install and build JS dependencies
run: cd web/app/themes/${{ env.THEME }} && yarn && yarn build:production
# Environment config
- name: Push files to the remote
run: rsync --progress -avz --chmod=Du=rwx,Dg=rx,Do=rx,Fu=rw,Fg=r,Fo=r --exclude=".git/" --exclude=".lando.yml" --exclude ".github/" --exclude "/web/app/themes/${{ env.THEME }}/node_modules/" --exclude "/web/app/themes/${{ env.THEME }}/resources/assets/" --exclude=".gitignore" --exclude "/web/app/themes/${{ env.THEME }}/package.json" --exclude "/web/app/themes/${{ env.THEME }}/.npmrc" --exclude "/web/app/themes/${{ env.THEME }}/yarn.lock"
-e 'ssh -o StrictHostKeyChecking=no -p ${{ env.SSH_PORT }}' ./ ${{ env.SSH_USERNAME }}@${{ env.SSH_HOST }}:${{ env.KINSTA_FOLDER }}
- name: Clear cache on kinsta
run: ssh ${{ env.SSH_USERNAME }}@${{ env.SSH_HOST }} -p ${{ env.SSH_PORT }} 'curl https://${{ env.DOMAIN }}/kinsta-clear-cache-all'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment