Merge pull request #732 from wmde/release/2023-11-01 #479
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: Build and Deploy to production on Toolforge | |
on: | |
push: | |
branches: | |
- main | |
concurrency: | |
group: '${{ github.workflow }}' | |
cancel-in-progress: true | |
jobs: | |
build-deploy: | |
name: Ship and Deploy | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Set up node | |
uses: actions/setup-node@v3.8.1 | |
with: | |
node-version: '18.x' | |
- name: Install composer dependencies | |
uses: php-actions/composer@v6 | |
with: | |
dev: no | |
version: 2 | |
php_version: 7.3 | |
php_extensions: zip | |
- name: Installing node dependencies | |
run: npm ci | |
- name: Minify and Build CSS and JS | |
run: "npm run prod" | |
- name: Remove node_modules before syncing | |
run: "rm -rf node_modules" | |
- name: Syncing code to Toolforge-Production | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
source: "./" | |
target: "mismatch-finder-repo" | |
rm: true | |
- name: Deploy code | |
uses: appleboy/ssh-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USERNAME }} | |
key: ${{ secrets.KEY }} | |
passphrase: ${{ secrets.PASSPHRASE }} | |
script: | | |
# Make sure ~tools.mismatch-finder/mismatch-finder-repo is group writable | |
become mismatch-finder chmod -R g+rwx ~tools.mismatch-finder/mismatch-finder-repo | |
# Change group of ~/mismatch-finder-repo (including symlinks) to tools.mismatch-finder | |
chgrp --no-dereference -R tools.mismatch-finder ~/mismatch-finder-repo | |
rsync -rlgD --delete --delay-updates --exclude '.nfs*' --exclude .env --exclude storage/app/ ~/mismatch-finder-repo ~tools.mismatch-finder/ | |
# take aborts recursion whenever it encounters a symlink, thus we use find+xargs to make sure all folders and file ares handled. | |
find ~tools.mismatch-finder/mismatch-finder-repo -type d,f \! -user tools.mismatch-finder -print0 | become mismatch-finder xargs -r --null take 2>&1 | { grep -vF 'will not follow or touch symlinks' || true; } |