Deploy to Github Pages #28
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: Deploy to Github Pages | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| version_bump: | |
| description: Version bump type | |
| required: true | |
| default: minor | |
| type: choice | |
| options: | |
| - patch | |
| - minor | |
| - major | |
| permissions: | |
| contents: write | |
| packages: write | |
| pages: write | |
| id-token: write | |
| concurrency: | |
| group: pages | |
| cancel-in-progress: false | |
| jobs: | |
| run-tests: | |
| name: Run Multi-Platform Tests | |
| # noinspection UndefinedAction | |
| uses: ./.github/workflows/lib_testing.yml | |
| secrets: inherit | |
| deploy: | |
| name: Deploy | |
| runs-on: ubuntu-latest | |
| needs: run-tests | |
| environment: | |
| name: github-pages | |
| url: ${{ steps.deployment.outputs.page_url }} | |
| steps: | |
| - name: Checkout repository | |
| uses: actions/checkout@v6 | |
| with: | |
| fetch-depth: 0 | |
| token: ${{ secrets.CORE_PUSH_TOKEN }} | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v5 | |
| with: | |
| dotnet-version: '10.x' | |
| - name: Setup Node | |
| uses: actions/setup-node@v6 | |
| with: | |
| node-version: '20.x' | |
| - name: Install npm dependencies | |
| run: npm ci | |
| working-directory: src/DirectiveAthenaWeb.Services.Js | |
| - name: Build interop bundle | |
| run: npm run build | |
| working-directory: src/DirectiveAthenaWeb.Services.Js | |
| - name: Run TypeScript unit tests | |
| run: npm run test:ts | |
| working-directory: src/DirectiveAthenaWeb.Services.Js | |
| - name: Bump site version | |
| id: version | |
| run: | | |
| version_file="src/DirectiveAthenaWeb.Client/wwwroot/version.txt" | |
| if [ ! -f "$version_file" ]; then | |
| echo "0.0.0" > "$version_file" | |
| fi | |
| current_version="$(cat "$version_file" | tr -d ' \n\r')" | |
| if ! [[ "$current_version" =~ ^[0-9]+\.[0-9]+\.[0-9]+$ ]]; then | |
| echo "Invalid version format: $current_version" | |
| exit 1 | |
| fi | |
| IFS='.' read -r major minor patch <<< "$current_version" | |
| bump_type="${{ inputs.version_bump }}" | |
| case "$bump_type" in | |
| major) | |
| major=$((major + 1)) | |
| minor=0 | |
| patch=0 | |
| ;; | |
| minor) | |
| minor=$((minor + 1)) | |
| patch=0 | |
| ;; | |
| patch) | |
| patch=$((patch + 1)) | |
| ;; | |
| *) | |
| echo "Invalid bump type: $bump_type" | |
| exit 1 | |
| ;; | |
| esac | |
| new_version="$major.$minor.$patch" | |
| echo "$new_version" > "$version_file" | |
| echo "version=$new_version" >> "$GITHUB_OUTPUT" | |
| - name: Commit version bump | |
| env: | |
| CORE_PUSH_TOKEN: ${{ secrets.CORE_PUSH_TOKEN }} | |
| run: | | |
| if [ -z "$CORE_PUSH_TOKEN" ]; then | |
| echo "CORE_PUSH_TOKEN is not set." | |
| exit 1 | |
| fi | |
| git config user.name "github-actions[bot]" | |
| git config user.email "github-actions[bot]@users.noreply.github.com" | |
| git add src/DirectiveAthenaWeb.Client/wwwroot/version.txt | |
| git commit -m "chore: bump version to ${{ steps.version.outputs.version }}" | |
| git tag "v${{ steps.version.outputs.version }}" | |
| git remote set-url origin "https://x-access-token:${CORE_PUSH_TOKEN}@github.com/${{ github.repository }}.git" | |
| git push origin HEAD | |
| git push origin --tags | |
| - name: Restore dependencies | |
| run: dotnet restore DirectiveAthenaWeb.GithubPages.slnf | |
| - name: Publish docs site | |
| run: | | |
| dotnet publish src/DirectiveAthenaWeb.Client -c Release -o ./out \ | |
| -p:PublishTrimmed=true \ | |
| -p:TrimMode=partial \ | |
| -p:DebuggerSupport=false \ | |
| -p:MetadataUpdaterSupport=false | |
| cp ./out/wwwroot/index.html ./out/wwwroot/404.html | |
| - name: List published files | |
| run: | | |
| echo "Published output:" | |
| ls -la ./out | |
| - name: Setup Pages | |
| uses: actions/configure-pages@v5 | |
| - name: Upload artifact | |
| uses: actions/upload-pages-artifact@v4 | |
| with: | |
| path: ./out/wwwroot | |
| - name: Deploy to GitHub Pages | |
| id: deployment | |
| uses: actions/deploy-pages@v4 | |
| - name: Create GitHub release | |
| uses: softprops/action-gh-release@v2 | |
| with: | |
| tag_name: v${{ steps.version.outputs.version }} | |
| name: Release v${{ steps.version.outputs.version }} | |
| generate_release_notes: true | |
| token: ${{ secrets.CORE_PUSH_TOKEN }} |