mirror of
https://gitee.com/ant-design-blazor/ant-design-blazor.git
synced 2024-11-29 18:48:50 +08:00
chore: add GitHub Actions for auto preview (#1205)
This commit is contained in:
parent
606d1f0c1a
commit
061e77e2b4
65
.github/workflows/preview-build.yml
vendored
Normal file
65
.github/workflows/preview-build.yml
vendored
Normal file
@ -0,0 +1,65 @@
|
||||
# Each PR will build preview site that help to check code is work as expect.
|
||||
|
||||
name: Preview Build
|
||||
|
||||
on: pull_request
|
||||
|
||||
jobs:
|
||||
|
||||
# Prepare
|
||||
setup:
|
||||
name: prepare preview
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: Setup .NET Core
|
||||
uses: actions/setup-dotnet@v1
|
||||
with:
|
||||
dotnet-version: 5.0.100
|
||||
|
||||
- name: Setup Node.js
|
||||
uses: actions/setup-node@v1
|
||||
with:
|
||||
node-version: "10.x"
|
||||
|
||||
build-site:
|
||||
name: build preview
|
||||
runs-on: ubuntu-latest
|
||||
needs: setup
|
||||
steps:
|
||||
- name: checkout
|
||||
uses: actions/checkout@master
|
||||
|
||||
- name: build site
|
||||
id: site
|
||||
run: |
|
||||
npm install
|
||||
dotnet build
|
||||
echo "/* updated `date "+%Y-%m-%d %H:%M:%S"` */" >> ./site/AntDesign.Docs.Wasm/wwwroot/service-worker.published.js
|
||||
cp -rf scripts/gh-pages/* scripts/gh-pages/.nojekyll scripts/gh-pages/.spa ./site/AntDesign.Docs.Wasm/wwwroot
|
||||
sed -i s/{version}/$PACKAGE_VERSION/g ./site/AntDesign.Docs.Wasm/wwwroot/index.html
|
||||
sed -i s/{version}/$PACKAGE_VERSION/g ./site/AntDesign.Docs/Shared/HeaderMenu.razor
|
||||
dotnet publish ./site/AntDesign.Docs.Wasm -c Release -f net5 -o _site
|
||||
with:
|
||||
PACKAGE_VERSION: ${{ github.event.number }}
|
||||
|
||||
- name: upload site artifact
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: site
|
||||
path: _site/wwwroot/
|
||||
retention-days: 5
|
||||
|
||||
# Upload PR id for next workflow use
|
||||
- name: Save PR number
|
||||
if: ${{ always() }}
|
||||
run: echo ${{ github.event.number }} > ./pr-id.txt
|
||||
|
||||
- name: Upload PR number
|
||||
if: ${{ always() }}
|
||||
uses: actions/upload-artifact@v2
|
||||
with:
|
||||
name: pr
|
||||
path: ./pr-id.txt
|
93
.github/workflows/preview-deploy.yml
vendored
Normal file
93
.github/workflows/preview-deploy.yml
vendored
Normal file
@ -0,0 +1,93 @@
|
||||
# Each PR will build preview site that help to check code is work as expect.
|
||||
|
||||
name: Preview Deploy
|
||||
|
||||
on:
|
||||
workflow_run:
|
||||
workflows: ["Preview Build"]
|
||||
types:
|
||||
- completed
|
||||
|
||||
jobs:
|
||||
deploy-site:
|
||||
name: deploy preview
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
github.event.workflow_run.conclusion == 'success'
|
||||
steps:
|
||||
# We need get PR id first
|
||||
- name: download pr artifact
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
name: pr
|
||||
|
||||
# Save PR id to output
|
||||
- name: save PR id
|
||||
id: pr
|
||||
run: echo "::set-output name=id::$(<pr-id.txt)"
|
||||
|
||||
# Download site artifact
|
||||
- name: download site artifact
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
workflow_conclusion: success
|
||||
name: site
|
||||
|
||||
- name: upload surge service
|
||||
id: deploy
|
||||
run: |
|
||||
export DEPLOY_DOMAIN=https://preview-${{ steps.pr.outputs.id }}-antblazor.surge.sh
|
||||
npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }}
|
||||
|
||||
- name: update status comment
|
||||
uses: actions-cool/maintain-one-comment@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
[<img width="306" src="https://user-images.githubusercontent.com/5378891/72400743-23dbb200-3785-11ea-9d13-1a2d92743846.png">](https://preview-${{ steps.pr.outputs.id }}-antblazor.surge.sh)
|
||||
<!-- AUTO_PREVIEW_HOOK -->
|
||||
body-include: '<!-- AUTO_PREVIEW_HOOK -->'
|
||||
number: ${{ steps.pr.outputs.id }}
|
||||
|
||||
- name: The job has failed
|
||||
if: ${{ failure() }}
|
||||
uses: actions-cool/maintain-one-comment@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
<img width="534" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">
|
||||
<!-- AUTO_PREVIEW_HOOK -->
|
||||
body-include: '<!-- AUTO_PREVIEW_HOOK -->'
|
||||
number: ${{ steps.pr.outputs.id }}
|
||||
|
||||
build-site-failed:
|
||||
name: build preview failed
|
||||
runs-on: ubuntu-latest
|
||||
if: >
|
||||
github.event.workflow_run.event == 'pull_request' &&
|
||||
github.event.workflow_run.conclusion == 'failure'
|
||||
steps:
|
||||
# We need get PR id first
|
||||
- name: download pr artifact
|
||||
uses: dawidd6/action-download-artifact@v2
|
||||
with:
|
||||
workflow: ${{ github.event.workflow_run.workflow_id }}
|
||||
name: pr
|
||||
|
||||
# Save PR id to output
|
||||
- name: save PR id
|
||||
id: pr
|
||||
run: echo "::set-output name=id::$(<pr-id.txt)"
|
||||
|
||||
- name: The job has failed
|
||||
uses: actions-cool/maintain-one-comment@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
<img width="534" src="https://user-images.githubusercontent.com/5378891/75333447-1e63a280-58c1-11ea-975d-235367fd1522.png">
|
||||
<!-- AUTO_PREVIEW_HOOK -->
|
||||
body-include: '<!-- AUTO_PREVIEW_HOOK -->'
|
||||
number: ${{ steps.pr.outputs.id }}
|
23
.github/workflows/preview-start.yml
vendored
Normal file
23
.github/workflows/preview-start.yml
vendored
Normal file
@ -0,0 +1,23 @@
|
||||
# When `preview-build` start. Leave a message on the PR
|
||||
#
|
||||
# 🚨🚨🚨 Important 🚨🚨🚨
|
||||
# Never do any `checkout` or `npm install` action!
|
||||
# `pull_request_target` will enable PR to access the secrets!
|
||||
|
||||
name: Preview Start
|
||||
|
||||
on: pull_request_target
|
||||
|
||||
jobs:
|
||||
preview-start:
|
||||
name: start preview info
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: update status comment
|
||||
uses: actions-cool/maintain-one-comment@v1.1.0
|
||||
with:
|
||||
token: ${{ secrets.GITHUB_TOKEN }}
|
||||
body: |
|
||||
![Prepare preview](https://user-images.githubusercontent.com/5378891/72351368-2c979e00-371b-11ea-9652-eb4e825d745e.gif)
|
||||
<!-- AUTO_PREVIEW_HOOK -->
|
||||
body-include: '<!-- AUTO_PREVIEW_HOOK -->'
|
Loading…
Reference in New Issue
Block a user