-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
67 additions
and
4 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -56,7 +56,4 @@ jobs: | |
push: true | ||
tags: user/my-app:latest | ||
context: . | ||
file: ./Dockerfile | ||
|
||
|
||
|
||
file: ./Dockerfile |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
# Based on this tutorial: https://github.com/marketplace/actions/ssh-deploy | ||
name: SSH Deploy | ||
on: | ||
workflow_dispatch: | ||
jobs: | ||
build: | ||
runs-on: ubuntu-22.04 | ||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v1 | ||
# Install PHP | ||
- name: Setup PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.2' | ||
coverage: none | ||
tools: composer:v2 | ||
extensions: mbstring, xml, ctype, iconv, intl, pdo_sqlite, dom, filter, gd, iconv, json, mbstring, pdo | ||
env: | ||
update: true | ||
- name: Check PHP Version | ||
run: php -v | ||
# Install backend dependencies (Composer) | ||
- name: Validate composer.json and composer.lock | ||
run: composer validate | ||
- name: Get composer cache directory | ||
id: composer-cache | ||
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | ||
- name: Cache composer dependencies | ||
uses: actions/cache@v1 | ||
with: | ||
path: ${{ steps.composer-cache.outputs.dir }} | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: ${{ runner.os }}-composer- | ||
- name: Install Composer dependencies | ||
run: composer install | ||
# Prepare .env file for production | ||
- name: Make production envfile | ||
uses: SpicyPizza/create-envfile@v1 | ||
with: | ||
envkey_APP_ENV: prod | ||
envkey_APP_DEBUG: false | ||
envkey_APP_SECRET: ${{ secrets.APP_SECRET }} | ||
file_name: .env | ||
# Copying files and artifacts via SSH | ||
- name: Copying files to server | ||
uses: appleboy/scp-action@master | ||
with: | ||
host: ${{ secrets.REMOTE_HOST }} | ||
username: ${{ secrets.REMOTE_USER }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
passphrase: '' | ||
rm: true | ||
source: "./" | ||
target: ${{ secrets.REMOTE_TARGET }} | ||
# Run commands on production | ||
- name: Executing remote ssh commands | ||
uses: appleboy/ssh-action@master | ||
with: | ||
host: ${{ secrets.REMOTE_HOST }} | ||
username: ${{ secrets.REMOTE_USER }} | ||
key: ${{ secrets.SERVER_SSH_KEY }} | ||
passphrase: '' | ||
script: | | ||
rsync -a --exclude={'var','temp'} --delete ${{ secrets.REMOTE_TARGET }} ${{ secrets.REMOTE_TARGET_DEPLOY }} | ||
cd ${{ secrets.REMOTE_TARGET }} && php8.2 bin/console cache:clear |