diff --git a/.github/workflows/deploy.yml b/.github/workflows/deploy.yml index 27b1c16..2c30b73 100644 --- a/.github/workflows/deploy.yml +++ b/.github/workflows/deploy.yml @@ -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 diff --git a/.github/workflows/preview.yml b/.github/workflows/preview.yml index 97d4ad5..7502d48 100644 --- a/.github/workflows/preview.yml +++ b/.github/workflows/preview.yml @@ -10,18 +10,68 @@ on: concurrency: preview-${{ github.ref }} +env: + BUILD_PATH: "." # default value when not using subfolders + POSTHOG_API_KEY: ${{ secrets.POSTHOG_API_KEY }} + ACTIONS_STEP_DEBUG: true + jobs: deploy-preview: runs-on: ubuntu-20.04 steps: - name: Checkout - uses: actions/checkout@v3 + uses: actions/checkout@v4 + + - name: Detect package manager + id: detect-package-manager + run: | + 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 and Build - if: github.event.action != 'closed' # You might want to skip the build if the PR has been closed + - 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: | - npm install - npm run build + ${{ 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 diff --git a/src/pages/test.md b/src/pages/test.md new file mode 100644 index 0000000..73a8b73 --- /dev/null +++ b/src/pages/test.md @@ -0,0 +1,8 @@ +--- +layout: "@/layouts/BaseLayout.astro" +title: Testy Test Test +--- + +## Hello, world + +This is a test page in a PR preview.