generated fromNetCoreTemplates/razor-ssg
- Notifications
You must be signed in to change notification settings - Fork0
Update index.json#932
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:Build | |
| permissions: | |
| contents:write | |
| on: | |
| push: | |
| branches: | |
| -'main' | |
| jobs: | |
| build: | |
| runs-on:ubuntu-latest | |
| steps: | |
| -name:checkout | |
| uses:actions/checkout@v2.0.0 | |
| -name:Setup dotnet | |
| uses:actions/setup-dotnet@v3 | |
| with: | |
| dotnet-version:8.* | |
| -name:build | |
| working-directory:./MyApp | |
| run:dotnet build . | |
| -name:Assign default GitHub URL base path | |
| env: | |
| GH_TOKEN:${{ secrets.GITHUB_TOKEN }} | |
| run:| | |
| custom_domain=$(gh api "/repos/${{ github.repository }}/pages" | jq -r '.cname // empty') | |
| echo "CNAME config detected: $custom_domain" | |
| repo_name=$(echo ${{ github.repository }} | cut -d '/' -f 2) | |
| org_name=$(echo ${{ github.repository_owner }} | tr '[:upper:]' '[:lower:]') | |
| if [ ! -f "./MyApp/wwwroot/CNAME" ] && [ ! custom_domain ] | |
| then | |
| echo "ssg_base_href=$(echo https://$org_name.github.io/$repo_name/)" >> $GITHUB_ENV | |
| else | |
| if [ custom_domain ] | |
| then | |
| # Persist CNAME settings | |
| echo "$custom_domain" > ./MyApp/wwwroot/CNAME | |
| fi | |
| fi | |
| -name:Install tailwindcss | |
| run:| | |
| mkdir -p /home/runner/.local/bin | |
| curl -o "/home/runner/.local/bin/tailwindcss" -L "https://github.com/tailwindlabs/tailwindcss/releases/latest/download/tailwindcss-linux-x64" | |
| chmod +x /home/runner/.local/bin/tailwindcss | |
| -name:Build tailwind | |
| working-directory:./MyApp | |
| run:| | |
| npm run build | |
| -name:prerender | |
| working-directory:./MyApp | |
| run:| | |
| site_base_href=${{ env.ssg_base_href }} | |
| if [ ! -z "$site_base_href" ] | |
| then | |
| echo "Prerendering for deployment to $site_base_href" | |
| dotnet run --no-launch-profile --AppTasks=prerender --configuration Release --environment Production --BaseHref "$site_base_href" | |
| else | |
| echo "Prerendering for deployment to $(cat ./wwwroot/CNAME)" | |
| dotnet run --no-launch-profile --AppTasks=prerender --configuration Release --environment Production | |
| fi | |
| # Deploy UI to GitHub Pages | |
| -name:Deploy to GitHub Pages | |
| uses:peaceiris/actions-gh-pages@v3 | |
| with: | |
| github_token:${{ secrets.GITHUB_TOKEN }} | |
| publish_dir:./MyApp/dist | |
| user_name:'GitHub Action' | |
| user_email:'action@github.com' | |
| -name:Configure AWS credentials | |
| uses:aws-actions/configure-aws-credentials@v1 | |
| with: | |
| aws-access-key-id:${{ secrets.AWS_ACCESS_KEY_ID }} | |
| aws-secret-access-key:${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
| aws-region:${{ secrets.AWS_REGION }} | |
| -name:Push to S3 prod | |
| working-directory:./MyApp | |
| run:| | |
| aws s3 sync ./dist/ s3://servicestack.net/ | |
| -name:Invalidate CloudFront Cache | |
| run:| | |
| aws cloudfront create-invalidation --distribution-id E3770UUEKTY40O --paths "/*" |