feat: add channel & user name #122
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: OpenPoll CI/CD | |
| on: | |
| push: | |
| branches: [main] | |
| tags: ['v*'] | |
| pull_request: | |
| branches: [main] | |
| env: | |
| NODE_VERSION: 22 | |
| jobs: | |
| setup: | |
| name: Setup | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies (root) | |
| run: npm ci | |
| lint: | |
| name: Lint ${{ matrix.app }} | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| strategy: | |
| matrix: | |
| app: [functions, web] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies (root) | |
| run: npm ci | |
| - name: Lint ${{ matrix.app }} | |
| run: npm -w ${{ matrix.app }} run lint | |
| test: | |
| name: Test ${{ matrix.app }} | |
| runs-on: ubuntu-latest | |
| needs: setup | |
| strategy: | |
| matrix: | |
| app: [functions] | |
| env: | |
| SLACK_BOT_TOKEN: test-token | |
| SLACK_SIGNING_SECRET: test-secret | |
| FIRESTORE_EMULATOR_HOST: localhost:8080 | |
| DEFAULT_FUNCTIONS_LOCATION: europe-west3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies (root) | |
| run: npm ci | |
| - name: Run ${{ matrix.app }} tests with coverage | |
| run: npm -w ${{ matrix.app }} run test:coverage | |
| integration_test: | |
| name: Integration Tests ${{ matrix.app }} | |
| runs-on: ubuntu-latest | |
| needs: test | |
| strategy: | |
| matrix: | |
| app: [functions] | |
| env: | |
| SLACK_BOT_TOKEN: test-token | |
| SLACK_SIGNING_SECRET: test-secret | |
| FIRESTORE_EMULATOR_HOST: localhost:8080 | |
| DEFAULT_FUNCTIONS_LOCATION: europe-west3 | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies (root) | |
| run: npm ci | |
| - name: Run ${{ matrix.app }} integration tests | |
| run: npm -w ${{ matrix.app }} run test:integration | |
| build: | |
| name: Build ${{ matrix.app }} | |
| runs-on: ubuntu-latest | |
| needs: [setup] | |
| strategy: | |
| matrix: | |
| app: [functions, web] | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| cache-dependency-path: package-lock.json | |
| - name: Install dependencies (root) | |
| run: npm ci | |
| - name: Build ${{ matrix.app }} | |
| run: npm -w ${{ matrix.app }} run build | |
| deploy_test: | |
| name: Deploy for Testing | |
| runs-on: ubuntu-latest | |
| needs: [lint, build, integration_test] | |
| environment: test | |
| if: startsWith(github.ref, 'refs/tags/') | |
| steps: | |
| - uses: actions/checkout@v4 | |
| - name: Use Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: ${{ env.NODE_VERSION }} | |
| cache: 'npm' | |
| - name: Install Firebase CLI | |
| run: npm install -g firebase-tools | |
| - name: Authenticate with Firebase | |
| run: | | |
| echo "${{ secrets.GOOGLE_APPLICATION_CREDENTIALS_BASE64 }}" | base64 -d > $HOME/gcp-key.json | |
| echo "GOOGLE_APPLICATION_CREDENTIALS=$HOME/gcp-key.json" >> $GITHUB_ENV | |
| - name: Configure Firebase Project | |
| run: | | |
| # Set the Firebase project using the secret | |
| firebase use ${{ secrets.FIREBASE_PROJECT_ID }} | |
| - name: Set .env values | |
| working-directory: functions | |
| run: | | |
| echo "SLACK_BOT_TOKEN=${{ secrets.SLACK_BOT_TOKEN_PROD }}" >> .env | |
| echo "SLACK_SIGNING_SECRET=${{ secrets.SLACK_SIGNING_SECRET_PROD }}" >> .env | |
| echo "DEFAULT_FUNCTIONS_LOCATION=${{ secrets.DEFAULT_FUNCTIONS_LOCATION }}" >> .env | |
| echo "NODE_ENV=production" >> .env | |
| - name: Install Dependencies | |
| working-directory: functions | |
| run: npm ci | |
| - name: Build Functions | |
| working-directory: functions | |
| run: npm run build | |
| - name: Set .env values for Web | |
| working-directory: web | |
| run: | | |
| echo "VITE_FIREBASE_API_KEY=${{ secrets.VITE_FIREBASE_API_KEY }}" >> .env | |
| echo "VITE_FIREBASE_AUTH_DOMAIN=${{ secrets.VITE_FIREBASE_AUTH_DOMAIN }}" >> .env | |
| echo "VITE_FIREBASE_PROJECT_ID=${{ secrets.VITE_FIREBASE_PROJECT_ID }}" >> .env | |
| echo "VITE_FIREBASE_STORAGE_BUCKET=${{ secrets.VITE_FIREBASE_STORAGE_BUCKET }}" >> .env | |
| echo "VITE_FIREBASE_MESSAGING_SENDER_ID=${{ secrets.VITE_FIREBASE_MESSAGING_SENDER_ID }}" >> .env | |
| echo "VITE_FIREBASE_APP_ID=${{ secrets.VITE_FIREBASE_APP_ID }}" >> .env | |
| echo "VITE_FIREBASE_MEASUREMENT_ID=${{ secrets.VITE_FIREBASE_MEASUREMENT_ID }}" >> .env | |
| echo "NODE_ENV=production" >> .env | |
| - name: Install Dependencies for Web | |
| working-directory: web | |
| run: npm ci | |
| - name: Build Web | |
| working-directory: web | |
| run: npm run build | |
| - name: Deploy to Firebase (Functions + Hosting) | |
| run: | | |
| firebase deploy --only functions,hosting |