New Kabyle Flag #232
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
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node | |
# For more information see: https://help.github.com/actions/language-and-framework-guides/using-nodejs-with-github-actions | |
name: Build | |
on: | |
push: | |
branches: ["master"] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
cache: 'npm' | |
node-version: 20 | |
- uses: actions/cache@v3 | |
with: | |
# See here for caching with `yarn` https://github.com/actions/cache/blob/main/examples.md#node---yarn or you can leverage caching with actions/setup-node https://github.com/actions/setup-node | |
path: | | |
~/.npm | |
${{ github.workspace }}/.next/cache | |
# Generate a new cache whenever packages or source files change. | |
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('**/*.js', '**/*.jsx', '**/*.ts', '**/*.tsx') }} | |
# If source files changed but packages didn't, rebuild from a prior cache. | |
restore-keys: | | |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json') }}- | |
- name: ssh tunnel to mysql database | |
run: | | |
mkdir -p ~/.ssh/ | |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}" | |
ssh -fN -L 3306:127.0.0.1:3306 duostori@ara.uberspace.de | |
ssh -fN -L 5432:127.0.0.1:5432 duostori@ara.uberspace.de | |
- name: Install | |
run: npm install | |
- run: printf "${{ secrets.ENV_LOCAL }}" >> .env.local | |
- name: Build | |
run: npm run build | |
- name: zip | |
run: zip -r build.zip .next | |
- name: Archive production artifacts | |
uses: actions/upload-artifact@v3 | |
with: | |
name: build-data | |
path: build.zip | |
deploy-beta: | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download build artifacts | |
uses: actions/download-artifact@v4.1.7 | |
with: | |
name: build-data | |
- name: ssh tunnel for upload | |
run: | | |
mkdir -p ~/.ssh/ | |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}" | |
ssh -fN -L 3306:127.0.0.1:3306 duostori@ara.uberspace.de | |
ssh -fN -L 5432:127.0.0.1:5432 duostori@ara.uberspace.de | |
- name: upload | |
run: | | |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}" | |
scp build.zip duostori@ara.uberspace.de:~/html/HEAD/ | |
- name: unzip | |
run: | | |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}" | |
ssh duostori@ara.uberspace.de 'rm -rf ~/html/HEAD/.next' | |
ssh duostori@ara.uberspace.de 'unzip -d ~/html/HEAD/ ~/html/HEAD/build.zip' | |
- name: restart | |
run: | | |
ssh-keyscan -H ara.uberspace.de >> ~/.ssh/known_hosts | |
eval `ssh-agent -s` | |
ssh-add - <<< "${{secrets.SSH_PRIVATE_KEY}}" | |
ssh duostori@ara.uberspace.de 'supervisorctl stop beta' | |
ssh duostori@ara.uberspace.de '/home/duostori/html/kill_rouge_workers.py' | |
ssh duostori@ara.uberspace.de '/home/duostori/html/kill_port_users.py beta' | |
ssh duostori@ara.uberspace.de 'supervisorctl start beta' |