Skip to content

Commit

Permalink
Update preview.yml to use same build steps as deploy.yml
Browse files Browse the repository at this point in the history
Add test.md.
  • Loading branch information
fwextensions committed Nov 30, 2024
1 parent a8ef806 commit 5efdee6
Show file tree
Hide file tree
Showing 3 changed files with 59 additions and 5 deletions.
1 change: 1 addition & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ jobs:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5
Expand Down
55 changes: 50 additions & 5 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,13 +15,58 @@ jobs:
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install and Build
if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed
- name: Detect package manager
id: detect-package-manager
run: |
npm install
npm run build
if [ -f "${{ github.workspace }}/yarn.lock" ]; then
echo "manager=yarn" >> $GITHUB_OUTPUT
echo "command=install" >> $GITHUB_OUTPUT
echo "runner=yarn" >> $GITHUB_OUTPUT
echo "lockfile=yarn.lock" >> $GITHUB_OUTPUT
exit 0
elif [ -f "${{ github.workspace }}/package.json" ]; then
echo "manager=npm" >> $GITHUB_OUTPUT
echo "command=ci" >> $GITHUB_OUTPUT
echo "runner=npx --no-install" >> $GITHUB_OUTPUT
echo "lockfile=package-lock.json" >> $GITHUB_OUTPUT
exit 0
else
echo "Unable to determine package manager"
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: "20"
cache: ${{ steps.detect-package-manager.outputs.manager }}
cache-dependency-path: ${{ env.BUILD_PATH }}/${{ steps.detect-package-manager.outputs.lockfile }}

- name: Setup Pages
id: pages
uses: actions/configure-pages@v5

- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
working-directory: ${{ env.BUILD_PATH }}

- name: Build with Astro
run: |
${{ steps.detect-package-manager.outputs.runner }} astro build \
--site "${{ steps.pages.outputs.origin }}" \
--base "${{ steps.pages.outputs.base_path }}"
working-directory: ${{ env.BUILD_PATH }}

# - name: Checkout
# uses: actions/checkout@v3
#
# - name: Install and Build
# if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed
# run: |
# npm install
# npm run build

- name: Deploy preview
uses: rossjrw/pr-preview-action@v1
Expand Down
8 changes: 8 additions & 0 deletions src/pages/test.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
---
layout: "@/layouts/BaseLayout.astro"
title: Testy Test Test
---

## Hello, world

This is a test page in a PR preview.

0 comments on commit 5efdee6

Please sign in to comment.