Repository navigation
Publish TimberLive #3
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: Publish TimberLive | |
| on: | |
| workflow_dispatch: | |
| permissions: | |
| contents: write | |
| concurrency: | |
| group: publish-timberlive | |
| cancel-in-progress: false | |
| jobs: | |
| build-and-publish: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - name: Checkout code | |
| uses: actions/checkout@v4 | |
| with: | |
| fetch-depth: 0 | |
| - name: Setup .NET | |
| uses: actions/setup-dotnet@v4 | |
| with: | |
| dotnet-version: '10.0.x' | |
| - name: Restore dependencies | |
| run: dotnet restore TimberLive/TimberLive.csproj | |
| - name: Publish TimberLive | |
| run: dotnet publish TimberLive/TimberLive.csproj --configuration Release --output /tmp/TimberLive-publish | |
| - name: Verify fingerprint placeholders were replaced | |
| run: | | |
| if grep -R "#\[.{fingerprint}\]" /tmp/TimberLive-publish/wwwroot/index.html; then | |
| echo "Fingerprint placeholder was not replaced in published index.html" | |
| exit 1 | |
| fi | |
| - name: Deploy to Cloudflare Pages | |
| uses: cloudflare/wrangler-action@v3 | |
| with: | |
| apiToken: ${{ secrets.CLOUDFLARE_API_TOKEN }} | |
| accountId: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} | |
| command: pages deploy /tmp/TimberLive-publish/wwwroot --project-name=timberlive | |
| - name: Checkout or create publish branch | |
| run: | | |
| git config user.name "GitHub Actions" | |
| git config user.email "actions@github.com" | |
| if git ls-remote --exit-code --heads origin TimberLive-publish; then | |
| git fetch origin TimberLive-publish | |
| git switch TimberLive-publish | |
| git reset --hard origin/TimberLive-publish | |
| else | |
| git switch --orphan TimberLive-publish | |
| git rm -rf . || true | |
| fi | |
| - name: Copy published files | |
| run: | | |
| rm -rf TimberLive | |
| mkdir -p TimberLive | |
| cp -a /tmp/TimberLive-publish/wwwroot/. TimberLive/ | |
| - name: Commit and push changes | |
| run: | | |
| git add TimberLive | |
| if git diff --cached --quiet; then | |
| echo "No changes to commit" | |
| else | |
| git commit -m "chore: publish TimberLive from ${{ github.sha }}" | |
| git push origin TimberLive-publish | |
| fi |