Build and deploy to production on main push or redeploy every 3 days #245
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 to production on main push or redeploy every 3 days | |
| on: | |
| push: | |
| branches: | |
| - main | |
| schedule: | |
| - cron: '0 0 */3 * *' | |
| jobs: | |
| web-deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| env: | |
| INSTAGRAM_API_LONG_LIVED_TOKEN: ${{ secrets.INSTAGRAM_API_LONG_LIVED_TOKEN }} | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| - name: Install Node.js 20 and dependencies | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: 20 | |
| - name: Install openconnect | |
| run: | | |
| sudo apt-get update | |
| sudo apt-get install -y openconnect | |
| - name: Connect to VPN | |
| run: | | |
| echo "${{ secrets.VPN_PASSWORD }}" > vpn-pass.txt | |
| sudo openconnect \ | |
| --protocol=anyconnect \ | |
| --user=${{ secrets.VPN_USERNAME }} \ | |
| vpn.utb.cz \ | |
| --passwd-on-stdin < vpn-pass.txt \ | |
| --background | |
| sleep 10 | |
| - name: Build project | |
| env: | |
| PUBLIC_GA_MEASUREMENT_ID: ${{ secrets.PUBLIC_GA_MEASUREMENT_ID }} | |
| run: npm ci && npm run build | |
| - name: SFTP uploader | |
| uses: wangyucode/sftp-upload-action@v2.0.2 | |
| with: | |
| host: ${{ secrets.FTP_SERVER }} | |
| username: ${{ secrets.FTP_USERNAME }} | |
| password: ${{ secrets.FTP_PASSWORD }} | |
| compress: false | |
| localDir: dist/ | |
| remoteDir: www/ |