From fbcd28c5ea9559f22855160a3368309302fc3eb7 Mon Sep 17 00:00:00 2001 From: Matyrobbrt <65940752+Matyrobbrt@users.noreply.github.com> Date: Tue, 26 Sep 2023 17:09:14 +0300 Subject: [PATCH] Add PR preview deployments --- .github/workflows/build-pr.yml | 25 +++++++++++++++++++++++++ .github/workflows/preview-pr.yml | 24 ++++++++++++++++++++++++ 2 files changed, 49 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 0000000..c6d4954 --- /dev/null +++ b/.github/workflows/build-pr.yml @@ -0,0 +1,25 @@ +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 + - name: Setup hugo + uses: peaceiris/actions-hugo@v2 + with: + hugo-version: "0.119.0" + + - name: Build + run: hugo + + - uses: matyrobbrt/cloudflare-pr-previews/upload@v1 + name: Upload website + with: + build-dir: ./public/ \ 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 0000000..f65608b --- /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-website-previews' + env: + CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }} + CLOUDFLARE_API_TOKEN: ${{ secrets.CLOUDFLARE_PAGES_API_TOKEN }} \ No newline at end of file