diff --git a/.github/workflows/pages.yml b/.github/workflows/pages.yml index d32d93a..106977f 100644 --- a/.github/workflows/pages.yml +++ b/.github/workflows/pages.yml @@ -6,16 +6,14 @@ on: workflow_dispatch: permissions: - contents: read - pages: write - id-token: write + contents: write concurrency: - group: pages + group: pages-main cancel-in-progress: false jobs: - build: + build-deploy: runs-on: ubuntu-latest steps: - uses: actions/checkout@v6 @@ -25,23 +23,20 @@ jobs: ruby-version: "3.3" bundler-cache: true - - name: Configure Pages - id: pages - uses: actions/configure-pages@v6 - - name: Build - run: bundle exec jekyll build --baseurl "${{ steps.pages.outputs.base_path }}" + run: bundle exec jekyll build --baseurl "/labs" env: JEKYLL_ENV: production - - uses: actions/upload-pages-artifact@v5 - - deploy: - runs-on: ubuntu-latest - needs: build - environment: - name: github-pages - url: ${{ steps.deploy.outputs.page_url }} - steps: - - id: deploy - uses: actions/deploy-pages@v5 + # Publish the built site to the root of the gh-pages branch. + # keep_files: true preserves the pr-preview/ subdirectories created + # by the PR Preview workflow so live previews are not wiped on a main deploy. + - name: Deploy to gh-pages + uses: peaceiris/actions-gh-pages@v4 + with: + github_token: ${{ secrets.GITHUB_TOKEN }} + publish_dir: ./_site + publish_branch: gh-pages + keep_files: true + user_name: "github-actions[bot]" + user_email: "github-actions[bot]@users.noreply.github.com" diff --git a/.github/workflows/pr-preview.yml b/.github/workflows/pr-preview.yml new file mode 100644 index 0000000..3c000ec --- /dev/null +++ b/.github/workflows/pr-preview.yml @@ -0,0 +1,47 @@ +name: PR Preview + +# Builds each pull request and publishes it to a per-PR subpath on the +# gh-pages branch, e.g. https://workato-devs.github.io/labs/pr-preview/pr-12/ +# The preview URL is auto-commented on the PR, and torn down when the PR +# is merged or closed. Stakeholders only need the URL — no repo access. + +on: + pull_request: + types: [opened, synchronize, reopened, closed] + +permissions: + contents: write + pull-requests: write + +concurrency: + group: pr-preview-${{ github.event.number }} + cancel-in-progress: true + +jobs: + preview: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v6 + + - uses: ruby/setup-ruby@v1 + if: github.event.action != 'closed' + with: + ruby-version: "3.3" + bundler-cache: true + + # baseurl must point at the preview subpath so Jekyll's url filters + # resolve correctly. (Internal links here are relative, so this is + # belt-and-suspenders, but keeps any generated URLs correct.) + - name: Build + if: github.event.action != 'closed' + run: bundle exec jekyll build --baseurl "/labs/pr-preview/pr-${{ github.event.number }}" + env: + JEKYLL_ENV: production + + - name: Deploy preview + uses: rossjrw/pr-preview-action@v1 + with: + source-dir: ./_site + preview-branch: gh-pages + umbrella-dir: pr-preview + action: auto