feat: Loading of assets in admin area. #46
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: Development Build | |
on: | |
push: | |
branches: [dev] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
defaults: | |
run: | |
shell: bash | |
steps: | |
- uses: actions/checkout@v3 | |
with: | |
fetch-depth: 2 | |
# Set up Node.js version 20 | |
- name: Set up Node.js 20 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
- name: Get Composer Cache Directory | |
id: composer-cache | |
run: | | |
echo "dir=$(composer config cache-files-dir)" >> $GITHUB_OUTPUT | |
- uses: actions/cache@v3 | |
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 -o | |
- name: Get npm cache directory | |
id: npm-cache-dir | |
shell: bash | |
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT} | |
- uses: actions/cache@v3 | |
id: npm-cache # use this to check for `cache-hit` ==> if: steps.npm-cache.outputs.cache-hit != 'true' | |
with: | |
path: ${{ steps.npm-cache-dir.outputs.dir }} | |
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install NPM Dependencies | |
run: npm install | |
- name: Build Scripts | |
run: npm run build | |
- name: Get .env Variables | |
id: dotenv | |
uses: falti/dotenv-action@v1.0.4 | |
- name: Sync Files to Server | |
env: | |
dest: '${{ steps.dotenv.outputs.SSH_LOGIN }}:${{ steps.dotenv.outputs.DEPLOYMENT_PATH }}${{ steps.dotenv.outputs.VITE_THEME_PATH }}' | |
deploy: '${{ steps.dotenv.outputs.DEPLOY }}' | |
if: ${{ env.deploy == 'TRUE' }} | |
run: | | |
echo "${{ secrets.DEPLOY_KEY }}" > deploy_key | |
chmod 600 ./deploy_key | |
# Deleting 'dist' folder on the server if it exists | |
echo "Checking and deleting 'dist' folder on the server if it exists..." | |
ssh -i ./deploy_key -o StrictHostKeyChecking=no ${{ steps.dotenv.outputs.SSH_LOGIN }} 'if [ -d "${{ steps.dotenv.outputs.DEPLOYMENT_PATH }}${{ steps.dotenv.outputs.VITE_THEME_PATH }}/dist" ]; then rm -rf ${{ steps.dotenv.outputs.DEPLOYMENT_PATH }}${{ steps.dotenv.outputs.VITE_THEME_PATH }}/dist; fi' | |
# Starting rsync operation | |
echo "Starting rsync operation..." | |
rsync -chav --delete \ | |
-e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' \ | |
--exclude-from='.git-ftp-ignore' \ | |
--exclude /deploy_key \ | |
./ ${{env.dest}} |