feat: api added to block and unblock district #26
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
| on: | |
| push: | |
| branches: ["main"] | |
| pull_request: | |
| branches: ["main"] | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Node jobs | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.17.0 | |
| - name: Install dependencies | |
| run: npm install --frozen-lockfile | |
| - name: Add the firebase service json | |
| run: | | |
| mkdir -p src/app/private | |
| echo '${{secrets.FIREBASE_SERVICE_JSON}}' > src/app/private/alyse-firebase.json | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Build app | |
| run: npm run build | |
| deploy: | |
| runs-on: ubuntu-latest | |
| needs: build | |
| steps: | |
| - uses: actions/checkout@v5 | |
| - name: Install Node jobs | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: 22.17.0 | |
| - name: Install dependencies | |
| run: npm install --frozen-lockfile | |
| - name: Add the firebase service json | |
| run: | | |
| mkdir -p src/app/private | |
| echo '${{secrets.FIREBASE_SERVICE_JSON}}' > src/app/private/alyse-firebase.json | |
| - name: Run linting | |
| run: npm run lint | |
| - name: Add .env file | |
| run: echo '${{secrets.ENV_VARIABLES}}' > .env | |
| - name: Build app | |
| run: npm run build | |
| - name: Configure SSH | |
| env: | |
| SSH_PRIVATE_KEY: ${{ secrets.SSH_PRIVATE_KEY }} | |
| run: | | |
| mkdir -p ~/.ssh | |
| echo "$SSH_PRIVATE_KEY" > ~/.ssh/id_rsa | |
| chmod 600 ~/.ssh/id_rsa | |
| ssh-keyscan -H ${{ secrets.EC2_HOST }} >> ~/.ssh/known_hosts | |
| - name: deploy to EC2 | |
| env: | |
| EC2_HOST: ${{secrets.EC2_HOST}} | |
| EC2_USER: ${{secrets.EC2_USER}} | |
| run: | | |
| # Create deployment directory | |
| ssh -i ~/.ssh/id_rsa $EC2_USER@$EC2_HOST "mkdir -p ~/server" | |
| # Copy files to EC2 instance | |
| rsync -avz \ | |
| --exclude='.git' \ | |
| --exclude='node_modules' \ | |
| --exclude='.github' \ | |
| . $EC2_USER@$EC2_HOST:~/server/ | |
| # Install prod dependencies on EC2 | |
| ssh -i ~/.ssh/id_rsa $EC2_USER@$EC2_HOST ' | |
| cd ~/server && | |
| eval "$(fnm env)" && | |
| npm install --frozen-lockfile' | |
| # Stop existing pm2 | |
| ssh -i ~/.ssh/id_rsa $EC2_USER@$EC2_HOST ' | |
| cd ~/server && | |
| eval "$(fnm env)" && | |
| pm2 delete server || true' | |
| # Start app with pm2 | |
| ssh -i ~/.ssh/id_rsa $EC2_USER@$EC2_HOST ' | |
| cd ~/server && | |
| eval "$(fnm env)" && | |
| pm2 reload server || pm2 start npm --name server -- run start' |