|
1 | | -name: CI |
| 1 | +name: Deploy to GitHub Pages |
2 | 2 |
|
3 | 3 | on: |
4 | 4 | push: |
5 | | - branches: |
6 | | - - main |
7 | | - pull_request: |
| 5 | + branches: [main] |
| 6 | + workflow_dispatch: |
8 | 7 |
|
9 | 8 | permissions: |
10 | | - actions: read |
11 | 9 | contents: read |
| 10 | + pages: write |
| 11 | + id-token: write |
| 12 | + |
| 13 | +concurrency: |
| 14 | + group: pages |
| 15 | + cancel-in-progress: true |
12 | 16 |
|
13 | 17 | jobs: |
14 | | - main: |
| 18 | + build: |
15 | 19 | runs-on: ubuntu-latest |
16 | 20 | steps: |
17 | | - - uses: actions/checkout@v4 |
| 21 | + - name: Checkout |
| 22 | + uses: actions/checkout@v4 |
18 | 23 | with: |
19 | | - filter: tree:0 |
20 | 24 | fetch-depth: 0 |
21 | 25 |
|
22 | | - # This enables task distribution via Nx Cloud |
23 | | - # Run this command as early as possible, before dependencies are installed |
24 | | - # Learn more at https://nx.dev/ci/reference/nx-cloud-cli#npx-nxcloud-startcirun |
25 | | - # Uncomment this line to enable task distribution |
26 | | - # - run: npx nx start-ci-run --distribute-on="3 linux-medium-js" --stop-agents-after="build" |
| 26 | + - name: Setup Pages |
| 27 | + uses: actions/configure-pages@v5 |
27 | 28 |
|
28 | | - # Cache node_modules |
29 | | - - uses: actions/setup-node@v4 |
| 29 | + - name: Setup Node |
| 30 | + uses: actions/setup-node@v4 |
30 | 31 | with: |
31 | 32 | node-version: 20 |
32 | | - cache: 'npm' |
| 33 | + cache: npm |
| 34 | + |
| 35 | + - name: Install deps |
| 36 | + run: npm ci |
33 | 37 |
|
34 | | - - run: npm ci |
| 38 | + - name: Build app |
| 39 | + run: npx nx build low-code-ide --configuration=production --base-href=/low-code-ide/ |
35 | 40 |
|
36 | | - # Prepend any command with "nx-cloud record --" to record its logs to Nx Cloud |
37 | | - # - run: npx nx-cloud record -- echo Hello World |
38 | | - # Nx Cloud recommends fixes for failures to help you get CI green faster. Learn more: https://nx.dev/ci/features/self-healing-ci |
39 | | - - run: npx nx fix-ci |
40 | | - if: always() |
| 41 | + - name: Add 404.html fallback |
| 42 | + run: | |
| 43 | + if [ -f dist/low-code-ide/index.html ]; then |
| 44 | + cp dist/low-code-ide/index.html dist/low-code-ide/404.html |
| 45 | + fi |
| 46 | + if [ -f dist/low-code-ide/browser/index.html ]; then |
| 47 | + cp dist/low-code-ide/browser/index.html dist/low-code-ide/browser/404.html |
| 48 | + fi |
| 49 | +
|
| 50 | + - name: Upload Pages artifact |
| 51 | + uses: actions/upload-pages-artifact@v4 |
| 52 | + with: |
| 53 | + path: dist/low-code-ide |
| 54 | + |
| 55 | + deploy: |
| 56 | + runs-on: ubuntu-latest |
| 57 | + needs: build |
| 58 | + environment: |
| 59 | + name: github-pages |
| 60 | + url: ${{ steps.deployment.outputs.page_url }} |
| 61 | + steps: |
| 62 | + - name: Deploy artifact |
| 63 | + id: deployment |
| 64 | + uses: actions/deploy-pages@v4 |
0 commit comments