From 7539bf5c8e7e34b5fda63d9fb9fa3beca06bba33 Mon Sep 17 00:00:00 2001 From: SHYAKA Davis <87414827+shyakadavis@users.noreply.github.com> Date: Sat, 3 Aug 2024 20:35:34 +0200 Subject: [PATCH] chore: Update deployment scripts (#638) Co-authored-by: Davis SHYAKA <87414827+davis-shyaka@users.noreply.github.com> Co-authored-by: AdrianGonz97 <31664583+AdrianGonz97@users.noreply.github.com> --- .github/workflows/build-preview.yml | 33 +++++++++++++++++ .github/workflows/deploy-preview.yml | 37 +++++++++++++++++++ .../{docs-production.yml => deploy-prod.yml} | 9 ++--- .github/workflows/release.yml | 1 + 4 files changed, 74 insertions(+), 6 deletions(-) create mode 100644 .github/workflows/build-preview.yml create mode 100644 .github/workflows/deploy-preview.yml rename .github/workflows/{docs-production.yml => deploy-prod.yml} (86%) diff --git a/.github/workflows/build-preview.yml b/.github/workflows/build-preview.yml new file mode 100644 index 000000000..262150c56 --- /dev/null +++ b/.github/workflows/build-preview.yml @@ -0,0 +1,33 @@ +name: Build Preview Deployment + +# cancel in-progress runs on new commits to same PR (github.event.number) +concurrency: + group: ${{ github.workflow }}-${{ github.event.number || github.sha }} + cancel-in-progress: true + +on: + pull_request: + types: [opened, synchronize] + +jobs: + build-preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + - uses: pnpm/action-setup@v4 + - uses: actions/setup-node@v4 + with: + node-version: 20 + cache: pnpm + + - name: Install dependencies + run: pnpm install + + - name: Build site + run: pnpm build + + - name: Upload build artifact + uses: actions/upload-artifact@v4 + with: + name: preview-build + path: sites/docs/.svelte-kit/cloudflare diff --git a/.github/workflows/deploy-preview.yml b/.github/workflows/deploy-preview.yml new file mode 100644 index 000000000..8b633d6cf --- /dev/null +++ b/.github/workflows/deploy-preview.yml @@ -0,0 +1,37 @@ +name: Upload Preview Deployment + +on: + workflow_run: + workflows: [Build Preview Deployment] + types: + - completed + +permissions: + actions: read + deployments: write + contents: read + pull-requests: write + +jobs: + deploy-preview: + runs-on: ubuntu-latest + if: ${{ github.event.workflow_run.conclusion == 'success' }} + steps: + - name: Download build artifact + uses: actions/download-artifact@v4 + id: preview-build-artifact + with: + name: preview-build + path: build + github-token: ${{ secrets.GITHUB_TOKEN }} + run-id: ${{ github.event.workflow_run.id }} + + - name: Deploy to Cloudflare Pages + uses: AdrianGonz97/refined-cf-pages-action@v1 + with: + apiToken: ${{ secrets.CF_API_TOKEN }} + accountId: ${{ secrets.CF_ACCOUNT_ID }} + githubToken: ${{ secrets.GITHUB_TOKEN }} + projectName: bits-ui + deploymentName: Preview + directory: ${{ steps.preview-build-artifact.outputs.download-path }} diff --git a/.github/workflows/docs-production.yml b/.github/workflows/deploy-prod.yml similarity index 86% rename from .github/workflows/docs-production.yml rename to .github/workflows/deploy-prod.yml index 84435a66c..11f6e9f52 100644 --- a/.github/workflows/docs-production.yml +++ b/.github/workflows/deploy-prod.yml @@ -1,6 +1,5 @@ -name: Docs - Production Deployment +name: Production Deployment on: - workflow_dispatch: push: branches: - main @@ -8,15 +7,13 @@ on: - sites/docs/** - packages/bits-ui/** -concurrency: ${{ github.workflow }}-${{ github.ref }} - jobs: - publish: + deploy-production: runs-on: ubuntu-latest permissions: contents: read deployments: write - name: Publish to Cloudflare Pages + name: Deploy Production Site to Cloudflare Pages steps: - uses: actions/checkout@v4 - uses: pnpm/action-setup@v4 diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3aeac2b83..952459464 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -21,6 +21,7 @@ jobs: with: # This makes Actions fetch all Git history so that Changesets can generate changelogs with the correct commits fetch-depth: 0 + - uses: pnpm/action-setup@v4 - uses: actions/setup-node@v4 with: