From da6e26f95c8bd77ca667618380abd36c4b55bbea Mon Sep 17 00:00:00 2001 From: cuisongliu Date: Wed, 6 Sep 2023 12:06:51 +0800 Subject: [PATCH] build(main): add docs for ci (#261) Signed-off-by: cuisongliu --- .github/gh-bot.yml | 30 ++++++++++ .github/workflows/deploy-docs.yml | 1 + .github/workflows/deploy-preview.yml | 90 ++++++++++++++++++++++++++++ 3 files changed, 121 insertions(+) create mode 100644 .github/gh-bot.yml create mode 100644 .github/workflows/deploy-preview.yml diff --git a/.github/gh-bot.yml b/.github/gh-bot.yml new file mode 100644 index 000000000..21908a40c --- /dev/null +++ b/.github/gh-bot.yml @@ -0,0 +1,30 @@ +version: v1 +debug: true +action: + printConfig: false + release: + retry: 15s + actionName: Release + allowOps: + - cuisongliu +bot: + prefix: / + spe: _ + allowOps: + - sealos-ci-robot + - sealos-release-robot + email: sealos-ci-robot@sealos.io + username: sealos-ci-robot +repo: + org: false + +message: + success: | + 🤖 says: Hooray! The action {{.Body}} has been completed successfully. 🎉 + format_error: | + 🤖 says: ‼️ There is a formatting issue with the action, kindly verify the action's format. + permission_error: | + 🤖 says: ‼️ The action doesn't have permission to trigger. + release_error: | + 🤖 says: ‼️ Release action failed. + Error details: {{.Error}} diff --git a/.github/workflows/deploy-docs.yml b/.github/workflows/deploy-docs.yml index 6b99ae219..6a9d52c47 100644 --- a/.github/workflows/deploy-docs.yml +++ b/.github/workflows/deploy-docs.yml @@ -69,3 +69,4 @@ jobs: github-comment: false vercel-args: '--prod --local-config ../vercel.json' # Optional working-directory: docSite/public + diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 000000000..28ada5410 --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,90 @@ +name: deploy-docs-preview + +on: + pull_request_target: + workflow_dispatch: + +# A workflow run is made up of one or more jobs that can run sequentially or in parallel +jobs: + # This workflow contains jobs "deploy-production" + deploy-preview: + # The environment this job references + environment: + name: Preview + url: ${{ steps.vercel-action.outputs.preview-url }} + + # The type of runner that the job will run on + runs-on: ubuntu-22.04 + + # Job outputs + outputs: + docs: ${{ steps.filter.outputs.docs }} + + # Steps represent a sequence of tasks that will be executed as part of the job + steps: + # Step 1 - Checks-out your repository under $GITHUB_WORKSPACE + - name: Checkout + uses: actions/checkout@v3 + with: + submodules: recursive # Fetch submodules + fetch-depth: 0 # Fetch all history for .GitInfo and .Lastmod + + # Step 2 Detect changes to Docs Content + - name: Detect changes in doc content + uses: dorny/paths-filter@v2 + id: filter + with: + filters: | + docs: + - 'docSite/content/docs/**' + base: main + + # Step 3 - Install Hugo (specific version) + - name: Install Hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: '0.117.0' + extended: true + + # Step 4 - Builds the site using Hugo + - name: Build + run: cd docSite && hugo mod get -u github.com/colinwilson/lotusdocs && hugo -v --minify + env: + HUGO_BASEURL: ${{ vars.BASE_URL }} + + # Step 5 - Push our generated site to Vercel + - name: Deploy to Vercel + uses: amondnet/vercel-action@v25 + id: vercel-action + with: + vercel-token: ${{ secrets.VERCEL_TOKEN }} # Required + vercel-org-id: ${{ secrets.VERCEL_ORG_ID }} #Required + vercel-project-id: ${{ secrets.VERCEL_PROJECT_ID }} #Required + github-comment: false + vercel-args: '--local-config ../vercel.json' # Optional + working-directory: docSite/public + alias-domains: | #Optional + fastgpt-staging.vercel.app + docsOutput: + needs: [ deploy-preview ] + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + with: + ref: ${{ github.event.pull_request.head.ref }} + repository: ${{ github.event.pull_request.head.repo.full_name }} + - name: Write md + run: | + echo "# 🤖 Generated by deploy action" > report.md + echo "[Deploy Actions Address](${{ needs.deploy-preview.outputs.docs }})" >> report.md + cat report.md + - name: Gh Rebot for Sealos + uses: labring/gh-rebot@v0.0.6 + if: ${{ (github.event_name == 'pull_request_target') }} + with: + version: v0.0.6 + env: + GH_TOKEN: "${{ secrets.GH_PAT }}" + SEALOS_TYPE: "pr_comment" + SEALOS_FILENAME: "report.md" + SEALOS_REPLACE_TAG: "DEFAULT_REPLACE_DEPLOY"