This repository has been archived by the owner on Jan 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ci(github-action): add workflow
build
## what - add workflow `build` - jobs - install: install npm packages and store to cache - lint: lint NextJS project - build: build NextJS project - semantic-release: run semantic-release ## how ## why - this will be used to CI/CD the repo - this will ensure the code is not breaking ## where - ./.github/workflows/build.yaml ## usage
- Loading branch information
1 parent
107fdd4
commit e3e5561
Showing
1 changed file
with
113 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,113 @@ | ||
--- | ||
name: NextJS build and release | ||
# description: lint, test, build and release NextJS | ||
on: push | ||
|
||
env: | ||
FORCE_COLOR: true # display terminal colors | ||
# APP_NAME: app_name | ||
# GHCR_IMAGE: ghcr.io/<user>/<repo name> | ||
CONTAINER_REGISTRY: ghcr.io | ||
IMAGE_NAME: clumsy-coder/uva-uhunt | ||
|
||
#################################################################################################### | ||
|
||
jobs: | ||
# install npm packages and store them as cache. | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: latest | ||
|
||
- name: Cache node modules | ||
id: cache-primes | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: ${{ runner.os }}-node- | ||
|
||
# skip npm ci if `package.json` didn't change | ||
# https://github.com/actions/cache#outputs | ||
# https://github.com/actions/cache#restoring-and-saving-cache-using-a-single-action | ||
- name: Install npm dependencies | ||
if: steps.cache-primes.outputs.cache-hit != 'true' | ||
run: npm ci --include=dev | ||
|
||
################################################################################################ | ||
# lint source code using ESlint and Typescript | ||
lint: | ||
needs: install | ||
runs-on: ubuntu-latest | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: latest | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: ${{ runner.os }}-node- | ||
|
||
- name: Lint project | ||
run: npm run lint | ||
|
||
################################################################################################ | ||
# build NextJS | ||
build: | ||
needs: install | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: latest | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: ${{ runner.os }}-node- | ||
|
||
- name: build NextJS | ||
run: npm run build | ||
|
||
################################################################################################ | ||
|
||
semantic-release: | ||
# prerequisite of a job that uses matrix | ||
# https://github.com/orgs/community/discussions/42010#discussioncomment-4439644 | ||
needs: build | ||
runs-on: ubuntu-latest | ||
if: github.ref == 'refs/heads/master' || github.ref == 'refs/heads/development' | ||
steps: | ||
- uses: actions/checkout@v4 | ||
with: | ||
persist-credentials: false | ||
- uses: actions/setup-node@v3 | ||
with: | ||
node-version: latest | ||
|
||
- name: Cache node modules | ||
uses: actions/cache@v3 | ||
with: | ||
path: node_modules | ||
key: ${{ runner.os }}-node-${{ hashFiles('**/package-lock.json') }} | ||
restore-keys: ${{ runner.os }}-node- | ||
|
||
- run: npm install --production=false | ||
|
||
- name: semantic-release | ||
run: npx semantic-release --ci | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.DEPENDABOT_TOKEN }} | ||
|
||
#################################################################################################### |