|
| 1 | +name: Build and Push |
| 2 | + |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - main |
| 7 | + - dev |
| 8 | + pull_request: |
| 9 | + branches: |
| 10 | + - main |
| 11 | + - dev |
| 12 | + |
| 13 | +env: |
| 14 | + NODE_VERSION: "20" |
| 15 | + |
| 16 | +jobs: |
| 17 | + build: |
| 18 | + runs-on: ubuntu-latest |
| 19 | + steps: |
| 20 | + - uses: actions/checkout@v4 |
| 21 | + |
| 22 | + - name: Setup pnpm |
| 23 | + uses: pnpm/action-setup@v4 |
| 24 | + with: |
| 25 | + version: latest |
| 26 | + |
| 27 | + - name: Setup Node.js |
| 28 | + uses: actions/setup-node@v4 |
| 29 | + with: |
| 30 | + node-version: ${{ env.NODE_VERSION }} |
| 31 | + cache: "pnpm" |
| 32 | + |
| 33 | + - name: Install dependencies |
| 34 | + working-directory: frontend |
| 35 | + run: pnpm install --frozen-lockfile |
| 36 | + |
| 37 | + - name: Generate sitemap |
| 38 | + working-directory: frontend |
| 39 | + run: | |
| 40 | + sudo apt-get update && sudo apt-get install -y python3 python3-pip |
| 41 | + pip3 install requests --break-system-packages |
| 42 | + python3 scripts/generate-sitemap.py || true |
| 43 | +
|
| 44 | + - name: Build |
| 45 | + working-directory: frontend |
| 46 | + run: pnpm run build |
| 47 | + |
| 48 | + - name: Upload dist |
| 49 | + uses: actions/upload-artifact@v4 |
| 50 | + with: |
| 51 | + name: dist |
| 52 | + path: frontend/dist/ |
| 53 | + |
| 54 | + docker: |
| 55 | + needs: build |
| 56 | + runs-on: ubuntu-latest |
| 57 | + if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/dev') |
| 58 | + steps: |
| 59 | + - uses: actions/checkout@v4 |
| 60 | + |
| 61 | + - name: Download dist |
| 62 | + uses: actions/download-artifact@v4 |
| 63 | + with: |
| 64 | + name: dist |
| 65 | + |
| 66 | + - name: Copy dist to docker |
| 67 | + run: cp -r dist frontend/docker/dist |
| 68 | + |
| 69 | + - name: Set up Docker Buildx |
| 70 | + uses: docker/setup-buildx-action@v3 |
| 71 | + |
| 72 | + - name: Login to GitHub Container Registry |
| 73 | + uses: docker/login-action@v3 |
| 74 | + with: |
| 75 | + registry: ghcr.io |
| 76 | + username: ${{ github.actor }} |
| 77 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 78 | + |
| 79 | + - name: Build and push |
| 80 | + uses: docker/build-push-action@v6 |
| 81 | + with: |
| 82 | + context: frontend/docker |
| 83 | + push: true |
| 84 | + tags: | |
| 85 | + ghcr.io/${{ github.repository_owner }}/monkeycode-frontend:${{ github.sha }} |
| 86 | + ghcr.io/${{ github.repository_owner }}/monkeycode-frontend:latest |
| 87 | + platforms: linux/amd64 |
0 commit comments