Deploy #26
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 | |
on: | |
# On tag release | |
push: | |
tags: | |
- "*" | |
schedule: | |
- cron: "0 0 1/7 * *" | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v1 | |
with: | |
node-version: "18.x" | |
- uses: shivammathur/setup-php@v2 | |
with: | |
php-version: "8.1" | |
extensions: intl zip | |
- name: Get composer cache directory | |
id: composer-cache | |
run: echo "::set-output name=dir::$(composer config cache-files-dir)" | |
- name: Cache dependencies | |
uses: actions/cache@v2 | |
with: | |
path: ${{ steps.composer-cache.outputs.dir }} | |
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | |
restore-keys: ${{ runner.os }}-composer- | |
- name: Cache node modules | |
id: cache-npm | |
uses: actions/cache@v3 | |
env: | |
cache-name: cache-node-modules | |
with: | |
# npm cache files are stored in `~/.npm` on Linux/macOS | |
path: ~/.npm | |
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-build-${{ env.cache-name }}- | |
${{ runner.os }}-build- | |
${{ runner.os }}- | |
- if: ${{ steps.cache-npm.outputs.cache-hit == false }} | |
name: List the state of node modules | |
continue-on-error: true | |
run: npm list | |
- name: Composer Install Packages | |
run: composer install --no-dev --no-interaction --no-progress --optimize-autoloader --prefer-dist | |
- name: Prepare Deployment | |
run: rsync -rvzt --include-from=.rsync --exclude-from=.gitignore --exclude '.rsync' ./ ./distribution/ | |
- name: Deploy | |
uses: SamKirkland/FTP-Deploy-Action@v4.3.5 | |
with: | |
local-dir: distribution/ | |
server-dir: ${{ secrets.DEPLOY_PATH }} | |
server: ${{ secrets.DEPLOY_HOST }} | |
username: ${{ secrets.DEPLOY_USER }} | |
password: ${{ secrets.DEPLOY_PASSWORD }} | |
port: ${{ secrets.DEPLOY_PORT }} | |
- name: Optimize Server | |
run: curl --location ${{ secrets.DEPLOY_URL }} |