Build Astro and Deploy to Firebase #60
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 Astro and Deploy to Firebase | |
| on: | |
| push: | |
| branches-ignore: | |
| - "dependabot/**" | |
| pull_request: | |
| schedule: | |
| - cron: "0 2 * * *" | |
| env: | |
| NODE_ENV: production | |
| YOUTUBE_API_KEY: ${{ secrets.YOUTUBE_API_KEY }} | |
| MEETUP_CLIENT_ID: ${{ secrets.MEETUP_CLIENT_ID }} | |
| MEETUP_PRIVATE_KEY: ${{ secrets.MEETUP_PRIVATE_KEY }} | |
| MEETUP_SIGNING_KEY_ID: ${{ secrets.MEETUP_SIGNING_KEY_ID }} | |
| MEETUP_MEMBER_ID: ${{ secrets.MEETUP_MEMBER_ID }} | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Clone repository | |
| uses: actions/checkout@v4 | |
| - name: Install node-canvas dependencies | |
| uses: awalsh128/cache-apt-pkgs-action@latest | |
| with: | |
| packages: build-essential libcairo2-dev libpango1.0-dev libjpeg-dev libgif-dev librsvg2-dev | |
| version: 1.0 | |
| - name: Setup Node.js | |
| uses: actions/setup-node@v4 | |
| with: | |
| node-version: "22" | |
| cache: "npm" | |
| - name: Cache Astro build | |
| uses: actions/cache@v4 | |
| with: | |
| path: | | |
| .astro/ | |
| node_modules/.astro/ | |
| key: ${{ runner.os }}-astro-${{ hashFiles('**/package-lock.json') }}-${{ hashFiles('src/**') }} | |
| restore-keys: | | |
| ${{ runner.os }}-astro-${{ hashFiles('**/package-lock.json') }}- | |
| ${{ runner.os }}-astro- | |
| - name: Install dependencies | |
| run: npm ci | |
| - name: Fetch external data (trainers, events, courses) | |
| run: npm run fetch:all | |
| - name: Generate OG images | |
| run: npm run generate:og | |
| - name: Build Astro site | |
| run: npm run build | |
| - name: Deploy to Production | |
| if: github.ref == 'refs/heads/master' | |
| uses: FirebaseExtended/action-hosting-deploy@v0 | |
| with: | |
| repoToken: "${{ secrets.GITHUB_TOKEN }}" | |
| firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_REACTJS_DE }}" | |
| channelId: live | |
| projectId: reactjs-de | |
| - name: Deploy Preview to Firebase | |
| if: github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository | |
| uses: FirebaseExtended/action-hosting-deploy@v0 | |
| with: | |
| repoToken: "${{ secrets.GITHUB_TOKEN }}" | |
| firebaseServiceAccount: "${{ secrets.FIREBASE_SERVICE_ACCOUNT_REACTJS_DE }}" | |
| projectId: reactjs-de |