From 6416bcdf7a62a2a81d13d9b5f6a6144e10c7ae95 Mon Sep 17 00:00:00 2001 From: haimlevy2006 Date: Sun, 30 Jun 2024 01:12:13 +0300 Subject: [PATCH] Add Preview Docs on PR --- .github/workflows/ci.yml.old | 30 ---------- .github/workflows/create-preview-on-pr.yaml | 61 +++++++++++++++++++++ .github/workflows/preview-prs.yaml | 29 ++++++++++ 3 files changed, 90 insertions(+), 30 deletions(-) delete mode 100644 .github/workflows/ci.yml.old create mode 100644 .github/workflows/create-preview-on-pr.yaml create mode 100644 .github/workflows/preview-prs.yaml diff --git a/.github/workflows/ci.yml.old b/.github/workflows/ci.yml.old deleted file mode 100644 index d2df9fef92..0000000000 --- a/.github/workflows/ci.yml.old +++ /dev/null @@ -1,30 +0,0 @@ -name: ci -on: - push: - branches: - - 'v*.*' - -jobs: - deploy: - runs-on: ubuntu-latest - steps: - - name: Extract branch name - shell: bash - run: echo "##[set-output name=branch;]$(echo ${GITHUB_REF#refs/heads/})" - id: extract_branch - - name: action checkout - uses: actions/checkout@v3 - - name: Python step - uses: actions/setup-python@v4 - with: - python-version: 3.x - - name: Cache setup - uses: actions/cache@v2 - with: - key: ${{ github.ref }} - path: .cache - - name: install requirements - run: pip3 install -r requirements.txt - # run: mkdocs gh-deploy --force - - name: Deploy using mike - run: mike deploy --push ${{ steps.extract_branch.outputs.branch }} diff --git a/.github/workflows/create-preview-on-pr.yaml b/.github/workflows/create-preview-on-pr.yaml new file mode 100644 index 0000000000..cb76735723 --- /dev/null +++ b/.github/workflows/create-preview-on-pr.yaml @@ -0,0 +1,61 @@ +# name: Create Preview for PRs + +# on: +# pull_request: +# branches: +# - master +# - v*.* + +# env: +# PR_NUMBER: ${{ github.event.number }} + +# jobs: +# comment-on-pr: +# runs-on: ubuntu-latest +# steps: +# - name: Comment on PR +# uses: hasura/comment-progress@v2.2.0 +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# repository: ${{ github.repository }} +# number: ${{ github.event.number }} +# id: deploy-preview +# message: "Starting deployment of preview ā³..." + +# create-preview: +# name: create preview +# runs-on: ubuntu-latest +# steps: +# - name: checkout latest +# uses: actions/checkout@v4 +# with: +# fetch-depth: 0 + +# - name: setup python +# uses: actions/setup-python@v5 +# with: +# python-version: '3.9' +# cache: 'pip' # caching pip dependencies + +# - name: install dependencies +# run: | +# pip3 install -r requirements.txt + +# - name: Configure Git User +# run: | +# git config user.name "circleci-runai" +# git config user.email "circleci-runai@run.ai" + +# - name: building preview +# run: | +# mike deploy ${{ env.PR_NUMBER }} ${{ env.PR_NUMBER }}-alias -t ${{ env.PR_NUMBER }} --prop-set hidden=true + +# - name: Update comment +# uses: hasura/comment-progress@v2.2.0 +# if: github.ref != 'refs/heads/main' +# with: +# github-token: ${{ secrets.GITHUB_TOKEN }} +# repository: ${{ github.repository }} +# number: ${{ github.event.number }} +# id: deploy-preview +# message: "A preview of ${{ github.event.after }} is uploaded and can be seen here:\n\n āœØ docs.run.ai/${{ env.PR_NUMBER }} āœØ\n\nšŸš€ Happy reviewing! šŸš€" \ No newline at end of file diff --git a/.github/workflows/preview-prs.yaml b/.github/workflows/preview-prs.yaml new file mode 100644 index 0000000000..6410051647 --- /dev/null +++ b/.github/workflows/preview-prs.yaml @@ -0,0 +1,29 @@ +name: Deploy PR previews + +on: + pull_request: + types: + - opened + - reopened + - synchronize + - closed + +concurrency: preview-${{ github.ref }} + +jobs: + deploy-preview: + runs-on: ubuntu-20.04 + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Install and Build + if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed + run: | + npm install + npm run build + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./site/ \ No newline at end of file