name: Deploy to Netlify on: push: branches: [main] pull_request: branches: [main] concurrency: group: ${{ github.workflow }}-${{ github.ref }} cancel-in-progress: true jobs: test: runs-on: ubuntu-latest steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - run: npm install --ignore-scripts - name: Install service dependencies run: | for dir in docker/services/ummahid docker/services/wallet docker/services/ramz docker/services/mocknet; do (cd "$dir" && npm install) done - run: npm test env: JWT_SECRET: test-jwt-secret-32-chars-minimum! ENCRYPTION_KEY: test-encryption-key-32-chars-min!!! ADMIN_SECRET: test-admin-secret POSTGRES_PASSWORD: test-postgres-password REDIS_PASSWORD: test-redis-password NODE_ENV: test CI: true deploy: runs-on: ubuntu-latest needs: test if: github.ref == 'refs/heads/main' && github.event_name == 'push' steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - run: npm install --ignore-scripts - run: npx netlify-cli deploy --dir=./netlify --functions=./netlify/functions --prod --message "Deploy ${{ github.sha }}" env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} preview: runs-on: ubuntu-latest needs: test if: github.event_name == 'pull_request' steps: - uses: actions/checkout@v4 - uses: actions/setup-node@v4 with: node-version: '20' - run: npm install --ignore-scripts - run: npx netlify-cli deploy --dir=./netlify --functions=./netlify/functions --message "Preview PR#${{ github.event.pull_request.number }}" env: NETLIFY_AUTH_TOKEN: ${{ secrets.NETLIFY_AUTH_TOKEN }} NETLIFY_SITE_ID: ${{ secrets.NETLIFY_SITE_ID }} notify-failure: runs-on: ubuntu-latest if: failure() && github.event_name == 'push' needs: [test, deploy] steps: - name: Send Slack notification uses: slackapi/slack-github-action@v1.25.0 with: payload: | { "text": "🚨 Falah OS Deployment Failed", "blocks": [{ "type": "section", "text": { "type": "mrkdwn", "text": "*Falah OS Deployment Failed!*\nRepo: ${{ github.repository }}\nBranch: ${{ github.ref_name }}\nCommit: ${{ github.sha }}\nWorkflow: ${{ github.workflow }}" } }] } env: SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK_URL }}