Skip to content

Commit

Permalink
New workflow to validate build
Browse files Browse the repository at this point in the history
  • Loading branch information
Forsyth-Creations committed Oct 17, 2023
1 parent f852d6b commit c7e877b
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 30 deletions.
63 changes: 34 additions & 29 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,12 @@ name: Deploy Next.js site to Pages

on:
# Runs on pushes targeting the default branch
pull_request:
branches:
- '*'
push:
branches: ["master"]
branches:
- ["master"]

# Allows you to run this workflow manually from the Actions tab
workflow_dispatch:
Expand All @@ -31,23 +35,23 @@ jobs:
steps:
- name: Checkout
uses: actions/checkout@v3
- 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
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
exit 0
else
echo "Unable to determine packager manager"
exit 1
fi
# - 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
# 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
# exit 0
# else
# echo "Unable to determine packager manager"
# exit 1
# fi
- name: Setup Node
uses: actions/setup-node@v3
with:
Expand All @@ -61,18 +65,18 @@ jobs:
#
# You may remove this line if you want to manage the configuration yourself.
static_site_generator: next
- name: Restore cache
uses: actions/cache@v3
with:
path: |
.next/cache
# Generate a new cache whenever packages or source files change.
key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# If source files changed but packages didn't, rebuild from a prior cache.
restore-keys: |
${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
# - name: Restore cache
# uses: actions/cache@v3
# with:
# path: |
# .next/cache
# # Generate a new cache whenever packages or source files change.
# key: ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-${{ hashFiles('**.[jt]s', '**.[jt]sx') }}
# # If source files changed but packages didn't, rebuild from a prior cache.
# restore-keys: |
# ${{ runner.os }}-nextjs-${{ hashFiles('**/package-lock.json', '**/yarn.lock') }}-
- name: Install dependencies
run: ${{ steps.detect-package-manager.outputs.manager }} ${{ steps.detect-package-manager.outputs.command }}
run: npm install
- name: Build with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next build
- name: Static HTML export with Next.js
Expand All @@ -84,6 +88,7 @@ jobs:

# Deployment job
deploy:
if: github.event_name == 'push' && github.ref == 'refs/heads/master'
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
Expand Down
2 changes: 1 addition & 1 deletion src/pages/soldering/general.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ export default function BeginnersGuide({fileContents}) {
}

export async function getStaticProps() {
const file = 'gen_soldering.md'
const file = 'basic_soldering.md'
const fileContents = await fs.readFile( process.cwd() + '/markdowns/' + file, 'utf8')
return {props: {fileContents}}
}
Expand Down

0 comments on commit c7e877b

Please sign in to comment.