Preview Publish #257
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: Preview Publish | |
| on: | |
| workflow_run: | |
| workflows: | |
| - Preview Build | |
| types: | |
| - completed | |
| jobs: | |
| preview-success: | |
| if: github.event.workflow_run.conclusion == 'success' | |
| runs-on: ubuntu-latest | |
| outputs: | |
| pr_id: ${{ steps.pr.outputs.id }} | |
| steps: | |
| - name: download pr id | |
| uses: dawidd6/action-download-artifact@v8 | |
| with: | |
| workflow: ${{ github.event.workflow_run.workflow_id }} | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: pr-id | |
| - name: output pr id | |
| id: pr | |
| run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT | |
| - name: Download playground | |
| uses: dawidd6/action-download-artifact@v8 | |
| with: | |
| workflow: ${{ github.event.workflow_run.workflow_id }} | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: playground | |
| - id: deploy | |
| run: | | |
| export DEPLOY_DOMAIN=https://preview-pr-${{ steps.pr.outputs.id }}-cherry-markdown.surge.sh | |
| npx surge --project ./ --domain $DEPLOY_DOMAIN --token ${{ secrets.SURGE_TOKEN }} | |
| echo "url=$DEPLOY_DOMAIN" >> $GITHUB_OUTPUT | |
| - uses: actions-cool/maintain-one-comment@v3 | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| body: | | |
| ### 【预览链接】 | |
| * [完整版](${{steps.deploy.outputs.url}}/index.html) | |
| * [基础](${{steps.deploy.outputs.url}}/basic.html) | |
| * [移动端](${{steps.deploy.outputs.url}}/h5.html) | |
| * [多实例](${{steps.deploy.outputs.url}}/multiple.html) | |
| * [无工具栏](${{steps.deploy.outputs.url}}/notoolbar.html) | |
| * [纯预览模式](${{steps.deploy.outputs.url}}/preview_only.html) | |
| * [XSS 测试](${{steps.deploy.outputs.url}}/xss.html)(默认禁用,需配置后允许) | |
| * [图片编辑](${{steps.deploy.outputs.url}}/img.html) | |
| * [表格编辑](${{steps.deploy.outputs.url}}/table.html) | |
| * [自动编号标题](${{steps.deploy.outputs.url}}/head_num.html) | |
| * [流式输入模式(AI chat 场景)](${{steps.deploy.outputs.url}}/ai_chat.html) | |
| * [VIM 编辑模式](${{steps.deploy.outputs.url}}/vim.html) | |
| * [使用自带或自定义的 Mermaid.js](${{steps.deploy.outputs.url}}/mermaid.html) | |
| * [自定义代码块外层容器](${{steps.deploy.outputs.url}}/custom_codeblock_wrapper.html) | |
| * [流式输出包](${{steps.deploy.outputs.url}}/ai_chat_stream.html) | |
| <!-- [工作流地址](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}) --> | |
| <!-- AUTO_PREVIEW_HOOK --> | |
| number: ${{ steps.pr.outputs.id }} | |
| body-include: '<!-- AUTO_PREVIEW_HOOK -->' | |
| preview-failed: | |
| runs-on: ubuntu-latest | |
| if: github.event.workflow_run.conclusion == 'failure' | |
| steps: | |
| - name: download pr id | |
| uses: dawidd6/action-download-artifact@v6 | |
| with: | |
| workflow: ${{ github.event.workflow_run.workflow_id }} | |
| run_id: ${{ github.event.workflow_run.id }} | |
| name: pr-id | |
| - name: output pr id | |
| id: pr | |
| run: echo "id=$(<pr-id.txt)" >> $GITHUB_OUTPUT | |
| - name: The job failed | |
| uses: actions-cool/maintain-one-comment@v3 | |
| with: | |
| token: ${{ secrets.BOT_TOKEN }} | |
| body: | | |
| 预览编译失败 | |
| <!-- [工作流地址](${{github.server_url}}/${{github.repository}}/actions/runs/${{github.run_id}}) --> | |
| <!-- AUTO_PREVIEW_HOOK --> | |
| number: ${{ steps.pr.outputs.id }} | |
| body-include: '<!-- AUTO_PREVIEW_HOOK -->' |