Skip to content

Instantly share code, notes, and snippets.

@mihai-valentin
Last active October 18, 2022 16:45
Show Gist options
  • Save mihai-valentin/b2683d124afe0b4f865af57f27fef869 to your computer and use it in GitHub Desktop.
Save mihai-valentin/b2683d124afe0b4f865af57f27fef869 to your computer and use it in GitHub Desktop.
Simple GitHub action for PHP project deployment
name: "Deploy a PHP project"
on:
push:
branches:
- master
jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: "Check out"
uses: actions/checkout@v3
- name: "Set up ssh key"
- run: |
set -eu
mkdir "$HOME/.ssh"
echo "${{ secrets.key }}" > "$HOME/.ssh/key"
chmod 600 "$HOME/.ssh/key"
- name: "Composer install"
run: composer install -q --no-ansi --no-interaction --no-scripts --no-progress --prefer-dist
- name: Sync
shell: bash
env:
USER: ${{ secrets.user }}
HOST: ${{ secrets.host }}
DIST: ${{ secrets.dist }}
run: rsync -avzO --no-perms -e "ssh -i $HOME/.ssh/key -o StrictHostKeyChecking=no" --delete * $USER@$HOST:$DIST
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment