Created
October 6, 2022 08:24
-
-
Save bokarios/49f6f49641b5018ac85a7731be31c361 to your computer and use it in GitHub Desktop.
Templates for github actions for number of frameworks
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
name: Deploy Laravel Backend | |
on: | |
push: | |
branches: | |
- [branch-name] | |
jobs: | |
// if your want to test first | |
test-backend: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v1 | |
with: | |
fetch-depth: 1 | |
- name: Install composer dependencies | |
run: | | |
composer install --no-scripts | |
- name: Prepare Backend | |
run: | | |
cp .env.example .env | |
php artisan key:generate | |
- name: Running tests | |
run: | | |
vendor/bin/phpunit tests | |
deploy-backend-to-production: | |
runs-on: ubuntu-latest | |
needs: test-backend | |
steps: | |
- name: Deploy with SSH | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: | | |
eval $(ssh-agent -s); | |
ssh-add ~/.ssh/[your-github-key]; | |
cd [path-to-project]; | |
git fetch --all; | |
git pull; | |
git reset --hard origin/[branch-name]; | |
composer install --optimize-autoloader; | |
php artisan config:cache; | |
php artisan route:cache; | |
php artisan view:cache; | |
php artisan migrate --force; | |
rm public/storage; | |
php artisan storage:link; | |
host: ${{ secrets.[your-ssh-host] }} | |
username: ${{ secrets.[your-ssh-user] }} | |
passphrase: ${{ secrets.[your-ssh-password] }} | |
privateKey: ${{ secrets.[your-ssh-private-key]}} |
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
name: Deploy Vue 3 App | |
on: | |
push: | |
branches: | |
- [branch-name] | |
jobs: | |
deploy-vue3-app: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy with SSH | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: | | |
eval $(ssh-agent -s); | |
ssh-add ~/.ssh/[your-github-key]; | |
cd /var/www/[path-to-project]; | |
git fetch --all; | |
git pull; | |
git reset --hard origin/[branch-name]; | |
npm install --quiet; | |
npm run build --quiet; | |
host: ${{ secrets.[your-ssh-host] }} | |
username: ${{ secrets.[your-ssh-user] }} | |
passphrase: ${{ secrets.[your-ssh-password] }} | |
privateKey: ${{ secrets.[your-ssh-private-key]}} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment