Merge pull request #433 from Computer-Research-Association/dev #93
This file contains hidden or 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 | |
| on: | |
| push: | |
| branches: ['main'] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout (with submodules) | |
| uses: actions/checkout@v4 | |
| with: | |
| submodules: true | |
| token: ${{ secrets.PAT_TOKEN }} | |
| fetch-depth: 0 | |
| - name: Set up Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: '22' | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Build (Vite) | |
| run: npm run build | |
| - name: Add 404.html (SPA fallback) | |
| run: | | |
| cd dist | |
| cp index.html 404.html | |
| - name: Setup SSH configuration | |
| run: | | |
| eval "$(ssh-agent -s)" | |
| mkdir -p ~/.ssh && chmod 700 ~/.ssh | |
| echo "${{ secrets.BASTION_KEY }}" > ~/.ssh/bastion.pem | |
| echo "${{ secrets.SERVER_KEY }}" > ~/.ssh/target.pem | |
| chmod 600 ~/.ssh/bastion.pem ~/.ssh/target.pem | |
| ssh-add ~/.ssh/bastion.pem | |
| ssh-add ~/.ssh/target.pem | |
| cat > ~/.ssh/config << 'EOF' | |
| Host bastion | |
| HostName ${{ secrets.BASTION_HOST }} | |
| User ${{ secrets.BASTION_USER }} | |
| IdentityFile ~/.ssh/bastion.pem | |
| StrictHostKeyChecking no | |
| UserKnownHostsFile /dev/null | |
| Host target | |
| HostName ${{ secrets.SERVER_HOST }} | |
| Port 2222 | |
| User ${{ secrets.SERVER_USERNAME }} | |
| IdentityFile ~/.ssh/target.pem | |
| ProxyJump bastion | |
| StrictHostKeyChecking no | |
| UserKnownHostsFile /dev/null | |
| EOF | |
| chmod 600 ~/.ssh/config | |
| - name: Deploy | |
| run: | | |
| ssh -F ~/.ssh/config target "mkdir -p ~/cra_web/dist && rm -rf ~/cra_web/dist/*" | |
| scp -F ~/.ssh/config -r ./dist/* target:~/cra_web/dist/ | |
| ssh -F ~/.ssh/config target "sudo nginx -t && sudo systemctl reload nginx" |