Improvements. #259
This file contains 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-22.04 | |
steps: | |
- name: checkout | |
uses: actions/checkout@v3 | |
- name: setup .net | |
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" ] && [ -z "$custom_domain" ] | |
then | |
echo "ssg_base_href=$(echo https://$org_name.github.io/$repo_name/)" | |
echo "ssg_base_href=$(echo https://$org_name.github.io/$repo_name/)" >> $GITHUB_ENV | |
else | |
if [ ! -z "$custom_domain" ] | |
then | |
echo "Persist CNAME '$custom_domain' to ./MyApp/wwwroot/CNAME" | |
echo "$custom_domain" >> ./MyApp/wwwroot/CNAME | |
echo "custom_domain=$custom_domain" >> $GITHUB_ENV | |
fi | |
fi | |
- name: Build tailwind | |
working-directory: ./MyApp | |
run: | | |
npm run build | |
- name: prerender | |
working-directory: ./MyApp | |
run: | | |
site_base_href=${{ env.ssg_base_href }} | |
site_base_url="https://${{ env.custom_domain }}" | |
if [ ! -z "$site_base_href" ] | |
then | |
echo "Prerendering for deployment to $site_base_href" | |
dotnet run --AppTasks=prerender --environment Production --BaseHref "$site_base_href" | |
else | |
echo "Prerendering for deployment to $custom_domain" | |
dotnet run --AppTasks=prerender --environment Production --BaseUrl "$site_base_url" | |
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: '[email protected]' |