fix header #44
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: C++ CI Push Main | |
on: | |
release: | |
types: [ published ] | |
branches: [ main ] | |
push: | |
branches: [main] | |
pull_request: | |
types: [ closed ] | |
branches: | |
- main | |
jobs: | |
build-and-publish-release: | |
runs-on: [self-hosted, Linux, X64, ubuntu-latest-lts] | |
if: ${{ github.event_name == 'push' && github.event.pull_request == null }} | |
steps: | |
- uses: actions/checkout@v4 | |
- name: Load NVM and Node | |
run: | | |
export NVM_DIR="$HOME/.nvm" | |
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" | |
nvm use node | |
- name: Source environment variables | |
run: | | |
sudo cp /srv/unforeseen-travels/.env ./ | |
sed -i 's/^PORT=.*/PORT=3400/' .env | |
source .env | |
- name: Install pnpm | |
run: sudo npm install -g pnpm | |
- name: Stop the production server | |
run: sudo systemctl stop unforeseen-travels || echo "Failed to stop the server, continuing..." | |
- name: Steal ownership of production server directory | |
run: sudo chown -R gh-runner:gh-runner /srv/unforeseen-travels | |
- name: Link existing node modules | |
run: sudo ln -s /srv/unforeseen-travels/node_modules /home/gh-runner/actions-runner/_work/unforeseen-travels/unforeseen-travels/ | |
- name: Install dependencies | |
run: pnpm install | |
- name: Build | |
run: pnpm build | |
- name: Publish Executable | |
if: success() | |
run: | | |
sudo find /srv/unforeseen-travels/ -mindepth 1 \ | |
! -path '/srv/unforeseen-travels/media*' \ | |
! -path '/srv/unforeseen-travels/node_modules*' \ | |
! -name '/srv/unforeseen-travels/.git*' \ | |
! -name '.env' \ | |
! -name 'log' \ | |
! -name 'tmp' -exec rm -rf {} + | |
sudo rsync -av --exclude 'node_modules' --exclude 'media' --exclude '.env' --exclude '.git' \ | |
--exclude 'log' --exclude 'tmp' /home/gh-runner/actions-runner/_work/unforeseen-travels/unforeseen-travels/ /srv/unforeseen-travels/ | |
- name: Install deps in prod after copy to be safe | |
if: success() | |
run: | | |
cd /srv/unforeseen-travels | |
pnpm install | |
- name: Handle failure | |
if: failure() | |
run: echo "Build failed, restoring permissions and restarting production server..." | |
- name: Restore permissions in production directory | |
if: always() | |
run: | | |
sudo chown -R www-data:www-data /srv/unforeseen-travels/ | |
sudo chmod -R 755 /srv/unforeseen-travels/ | |
sudo chown -R gh-runner:gh-runner /home/gh-runner/ | |
- name: Start production server | |
if: always() | |
run: sudo systemctl start unforeseen-travels |