diff --git a/.github/workflows/preview-build.yml b/.github/workflows/preview-build.yml new file mode 100644 index 000000000..53b2e817a --- /dev/null +++ b/.github/workflows/preview-build.yml @@ -0,0 +1,66 @@ +name: Preview Build + +on: + pull_request: + types: [opened, synchronize, reopened] + +concurrency: + group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.ref }} + cancel-in-progress: true + +jobs: + build-site: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - name: Setup pnpm + uses: pnpm/action-setup@v2 + with: + version: 8.3.1 + + - name: Setup node + uses: actions/setup-node@v3 + with: + node-version: 20 + - name: Get pnpm store directory + id: pnpm-cache + run: | + echo "pnpm_cache_dir=$(pnpm store path)" >> $GITHUB_OUTPUT + + - uses: actions/cache@v3 + name: Setup pnpm cache + with: + path: ${{ steps.pnpm-cache.outputs.pnpm_cache_dir }} + key: ${{ runner.os }}-pnpm-store-${{ hashFiles('**/pnpm-lock.yaml') }} + restore-keys: | + ${{ runner.os }}-pnpm-store- + + - name: Install dependencies + run: pnpm install + + - name: Build website + run: pnpm build:site + env: + NODE_OPTIONS: --max-old-space-size=4096 + + - name: Compressed into zip + run: | + zip -r site.zip examples/sites/dist/ + + - name: Upload Site Artifact + uses: actions/upload-artifact@v3 + with: + name: site + path: site.zip + retention-days: 3 + + - name: Save PR number + if: ${{ always() }} + run: echo ${{ github.event.number }} > ./pr-id.txt + + - name: Upload PR number + if: ${{ always() }} + uses: actions/upload-artifact@v3 + with: + name: pr + path: ./pr-id.txt diff --git a/.github/workflows/preview-deploy.yml b/.github/workflows/preview-deploy.yml new file mode 100644 index 000000000..9a5188b2e --- /dev/null +++ b/.github/workflows/preview-deploy.yml @@ -0,0 +1,77 @@ +name: Preview Deploy + +on: + workflow_run: + workflows: ['Preview Build'] + types: + - completed + +jobs: + success: + name: Build successfully + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download Pr Artifact + uses: dawidd6/action-download-artifact@v2 + with: + workflow: ${{ github.event.workflow_run.workflow_id }} + name: pr + - name: Save PR Id + id: pr + run: echo "::set-output name=id::$(