From 708ab42ed869d742a36af6b4fc50bd7ddce55b0e Mon Sep 17 00:00:00 2001 From: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> Date: Fri, 28 Jul 2023 15:12:25 +0300 Subject: [PATCH] Add actions to build and preview PRs --- .github/workflows/build-pr.yml | 26 ++++++++++++++++++++++++++ .github/workflows/preview-pr.yml | 24 ++++++++++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 .github/workflows/build-pr.yml create mode 100644 .github/workflows/preview-pr.yml diff --git a/.github/workflows/build-pr.yml b/.github/workflows/build-pr.yml new file mode 100644 index 000000000..0bee98d30 --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,26 @@ +name: 'Build Pull Request' +run-name: Build and upload preview for PR ${{ github.event.pull_request.number }} + +on: + pull_request: + types: [synchronize, opened] + +jobs: + build: + name: Build and upload site + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v3 + - uses: actions/setup-node@v3 + with: + node-version: 18 + cache: npm + + - name: Install dependencies + run: npm install + - name: Build website + run: npm run build + - uses: matyrobbrt/cloudflare-pr-previews/upload@v1 + name: Upload website + with: + build-dir: ./build/ \ No newline at end of file diff --git a/.github/workflows/preview-pr.yml b/.github/workflows/preview-pr.yml new file mode 100644 index 000000000..0397a171b --- /dev/null +++ b/.github/workflows/preview-pr.yml @@ -0,0 +1,24 @@ +name: 'Pull Request Previews' +run-name: Upload previews from workflow run ${{ github.event.workflow_run.id }} +on: + workflow_run: + workflows: [Build Pull Request] + types: + - completed + +concurrency: + group: preview-pr + cancel-in-progress: false + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: matyrobbrt/cloudflare-pr-previews@v1 + with: + gh_app_key: ${{ secrets.CLOUDFLARE_PAGES_DEPLOYMENTS_GH_APP_KEY }} + gh_app_name: ${{ secrets.CLOUDFLARE_PAGES_DEPLOYMENTS_GH_APP_NAME }} + project_name: 'neoforged-docs-previews' + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }} \ No newline at end of file