Deploy Development Build #9
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 development build | |
on: | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
deploy: | |
name: 🎉 Deploy devlopment build to dev.playdeathgarden.live | |
runs-on: ubuntu-latest | |
environment: Dev | |
defaults: | |
run: | |
working-directory: ./dist | |
steps: | |
- name: 🚚 Get latest code | |
uses: actions/checkout@v4 | |
with: | |
fetch-depth: 0 | |
- name: Install lftp | |
run: sudo apt-get install lftp | |
- name: Validate composer.json and composer.lock | |
run: composer validate | |
- name: 🧳 Cache Composer dependencies | |
id: composer-cache | |
uses: actions/cache@v4 | |
with: | |
path: vendor | |
key: ${{ runner.os }}-node-${{ hashFiles('**/composer.lock') }} | |
restore-keys: | | |
${{ runner.os }}-node- | |
- name: Install dependencies | |
if: steps.composer-cache.outputs.cache-hit != 'true' | |
run: composer install --prefer-dist --no-progress --ignore-platform-reqs | |
- name: Use Node.js 20 | |
uses: actions/setup-node@v4 | |
with: | |
node-version: '20' | |
cache: 'npm' | |
cache-dependency-path: ./dist/package-lock.json | |
- name: 🔨 Build Project | |
run: | | |
npm install | |
npm run build | |
- name: Generate maintenance file | |
run: php artisan down | |
- name: Generate vendor archive | |
run: php artisan zip:create ./vendor vendor | |
- name: Generate temporary migration key | |
id: migration_key | |
run: | | |
echo "migrationKey=$(php artisan migration_key:generate)" >> $GITHUB_OUTPUT | |
#- name: Generate public vendor archive | |
# run: php artisan zip:create ./public/assets/vendor vendor_public | |
- name: 📂 Upload to server | |
run: | | |
echo Connecting to FTP server | |
lftp ${{ secrets.FTP_HOST }} -u '${{ secrets.FTP_USER }}','${{ secrets.FTP_PASS }}' -e "set ftp:ssl-force no; set ssl:verify-certificate false; | |
echo Uploading maintenance file | |
put -O ./storage/framework storage/framework/down; | |
put -O ./storage/framework storage/framework/maintenance.php; | |
echo Backup config file | |
mv .env .env_back; | |
echo Uploading files | |
mirror -p --parallel=10 --reverse --continue --dereference --only-newer --delete --verbose=3 --exclude ^.git/ --exclude ^.github/ --exclude ^node_modules/ --exclude ^vendor/ --exclude ^public/assets/vendor --exclude ^.env_back --exclude ^.htaccess . ./; | |
echo Renaming directories | |
rm ./storage/framework/down; | |
rm ./storage/framework/maintenance.php; | |
echo Moving config file | |
mv .env_back .env; | |
quit;" | |
- name: Extract vendor and public vendor archives | |
run: wget --debug -qO- ${{ vars.URL_VENDOR_UNZIP }} | |
- name: Run migrations and seeders | |
run: wget --debug -qO- ${{ secrets.URL_MIGRATIONS }}?migration_key=${{ steps.migration_key.outputs.migrationKey }} | |