Skip to content

Commit

Permalink
New workflow to validate build (#118)
Browse files Browse the repository at this point in the history
* New workflow to validate build
  • Loading branch information
Forsyth-Creations authored Oct 17, 2023
1 parent f852d6b commit 6a0cb45
Show file tree
Hide file tree
Showing 7 changed files with 41 additions and 104 deletions.
69 changes: 37 additions & 32 deletions .github/workflows/nextjs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,16 @@
#
# To get started with Next.js see: https://nextjs.org/docs/getting-started
#
name: Deploy Next.js site to Pages
name: CI/CD Pipeline for Amp Lab Website

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,29 +65,30 @@ 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
run: npm run build
- name: Static HTML export with Next.js
run: ${{ steps.detect-package-manager.outputs.runner }} next export
run: npm run export
- name: Upload artifact
uses: actions/upload-pages-artifact@v1
with:
path: ./out

# 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
1 change: 1 addition & 0 deletions next.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,6 @@ module.exports = {
pathname: "/**",
},
],
unoptimized: true,
},
};
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"dev": "next dev",
"build": "next build",
"start": "next start",
"lint": "next lint"
"lint": "next lint",
"export": "next export"
},
"dependencies": {
"@types/node": "18.15.0",
Expand Down
23 changes: 0 additions & 23 deletions src/pages/adv_soldering.jsx

This file was deleted.

24 changes: 0 additions & 24 deletions src/pages/basic_soldering.jsx

This file was deleted.

23 changes: 0 additions & 23 deletions src/pages/beginners_guide.jsx

This file was deleted.

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 6a0cb45

Please sign in to comment.