|
| 1 | +# Simple workflow for deploying static content to GitHub Pages |
| 2 | +name: Deploy Component Storybook |
| 3 | +env: |
| 4 | + PUBLISH_DIR: Mythetech.Components.Storybook/bin/Release/net9.0/publish/wwwroot |
| 5 | + |
| 6 | +on: |
| 7 | + # Runs on pushes targeting the default branch and PRs |
| 8 | + push: |
| 9 | + paths: |
| 10 | + - Mythetech.Components.*/** |
| 11 | + - '.github/workflows/storybook.yml' |
| 12 | + branches: |
| 13 | + - main |
| 14 | + pull_request: |
| 15 | + branches: |
| 16 | + - main |
| 17 | + |
| 18 | + # Allows you to run this workflow manually from the Actions tab |
| 19 | + workflow_dispatch: |
| 20 | + |
| 21 | +# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages |
| 22 | +permissions: |
| 23 | + contents: read |
| 24 | + pages: write |
| 25 | + id-token: write |
| 26 | + |
| 27 | +# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued. |
| 28 | +# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete. |
| 29 | +concurrency: |
| 30 | + group: "pages" |
| 31 | + cancel-in-progress: false |
| 32 | + |
| 33 | +jobs: |
| 34 | + test: |
| 35 | + runs-on: ubuntu-latest |
| 36 | + steps: |
| 37 | + - name: Checkout |
| 38 | + uses: actions/checkout@v4 |
| 39 | + |
| 40 | + - name: Get latest .NET SDK |
| 41 | + uses: actions/setup-dotnet@v4 |
| 42 | + with: |
| 43 | + dotnet-version: '9.0' |
| 44 | + |
| 45 | + - name: Install .Net WASM workload |
| 46 | + run: dotnet workload install wasm-tools |
| 47 | + |
| 48 | + - name: Run Tests |
| 49 | + run: dotnet test Mythetech.Components.Test --logger trx --results-directory "TestResults-${{ matrix.dotnet-version }}" |
| 50 | + |
| 51 | + - name: Upload dotnet test results |
| 52 | + uses: actions/upload-artifact@v4 |
| 53 | + with: |
| 54 | + name: dotnet-results-${{ matrix.dotnet-version }} |
| 55 | + path: TestResults-${{ matrix.dotnet-version }} |
| 56 | + if: ${{ always() }} |
| 57 | + |
| 58 | + # Deploy job |
| 59 | + deploy: |
| 60 | + needs: test # Only deploy if tests pass |
| 61 | + if: github.event_name == 'push' || github.event_name == 'workflow_dispatch' # Only deploy on push to main or manual trigger |
| 62 | + environment: |
| 63 | + name: github-pages |
| 64 | + url: ${{ steps.deployment.outputs.page_url }} |
| 65 | + runs-on: ubuntu-latest |
| 66 | + steps: |
| 67 | + - name: Checkout |
| 68 | + uses: actions/checkout@v4 |
| 69 | + |
| 70 | + - name: Get latest .NET SDK |
| 71 | + uses: actions/setup-dotnet@v4 |
| 72 | + with: |
| 73 | + dotnet-version: '9.0' |
| 74 | + |
| 75 | + - name: Install .Net WASM workload |
| 76 | + run: dotnet workload install wasm-tools |
| 77 | + |
| 78 | + - name: Publish app |
| 79 | + run: dotnet publish Mythetech.Components.Storybook -c Release |
| 80 | + |
| 81 | + - name: Rewrite base href |
| 82 | + uses: SteveSandersonMS/ghaction-rewrite-base-href@v1 |
| 83 | + with: |
| 84 | + html_path: ${{ env.PUBLISH_DIR }}/index.html |
| 85 | + base_href: /Mythetech.Components.Storybook/ |
| 86 | + |
| 87 | + - name: Setup Pages |
| 88 | + uses: actions/configure-pages@v5 |
| 89 | + |
| 90 | + - name: Upload artifact |
| 91 | + uses: actions/upload-pages-artifact@v3 |
| 92 | + with: |
| 93 | + path: ${{ env.PUBLISH_DIR }} |
| 94 | + |
| 95 | + - name: Deploy to GitHub Pages |
| 96 | + id: deployment |
| 97 | + uses: actions/deploy-pages@v4 |
0 commit comments