Skip to content

Merge pull request #101 from DonColon/dev #211

Merge pull request #101 from DonColon/dev

Merge pull request #101 from DonColon/dev #211

Workflow file for this run

name: Node CI Build
on:
push:
branches: ["main", "dev", "feature**"]
jobs:
code_quality:
name: Check Code Quality
runs-on: ubuntu-latest
timeout-minutes: 30
env:
node_version: 20.x
steps:
- name: Checkout Repository ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Setup Node Version ${{ env.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Check Prettier Rules
run: npm run format:check --if-present
- name: Check ESLint Rules
run: npm run lint --if-present
- name: Check Sonarcloud Rules
uses: SonarSource/sonarcloud-github-action@master
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
SONAR_TOKEN: ${{ secrets.SONAR_TOKEN }}
build:
name: Build Application
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node_version: [16.x, 18.x, 20.x]
steps:
- name: Checkout Repository ${{ github.event.repository.name }}
uses: actions/checkout@v4
- name: Setup Node Version ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Build Application
run: npm run build --if-present
- name: Application Version
uses: actions/github-script@v7
id: app_version
with:
result-encoding: string
script: |
const pkg = require('./package.json');
core.info(`Application Version: ${pkg.version}`);
return `v${pkg.version}`;
- name: Upload Build Artifact
uses: actions/upload-artifact@v4
if: ${{ matrix.node_version == '20.x' }}
with:
name: ${{ github.event.repository.name }}-build-${{steps.app_version.outputs.result}}
path: dist
test:
name: Test Application
runs-on: ubuntu-latest
timeout-minutes: 30
strategy:
fail-fast: false
matrix:
node_version: [16.x, 18.x, 20.x]
steps:
- name: Checkout Repository ${{ github.event.repository.name }}
uses: actions/checkout@v4
- name: Setup Node Version ${{ matrix.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node_version }}
cache: "npm"
- name: Install Dependencies
run: npm ci
- name: Test Application with Coverage Report
run: npm run test:coverage --if-present
- name: Publish Coverage Report
uses: codecov/codecov-action@v3
if: ${{ matrix.node_version == '20.x' }}
env:
CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }}
release:
name: Release Application
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [code_quality, build, test]
steps:
- name: Checkout Repository ${{ github.event.repository.name }}
uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Retrieve Latest Release
uses: actions/github-script@v7
id: retrieve_latest_release
with:
script: |
const scriptPath = '${{ github.workspace }}/.github/scripts/retrieve-latest-release.js';
const { default: retrieveLatestRelease } = await import(scriptPath);
await retrieveLatestRelease({ core, context, github });
- name: Upload Release Asset
uses: actions/github-script@v7
id: upload_release_asset
with:
script: |
const scriptPath = '${{ github.workspace }}/.github/scripts/upload-release-asset.js';
const release = ${{ steps.retrieve_latest_release.outputs.release }};
const { default: uploadReleaseAsset } = await import(scriptPath);
await uploadReleaseAsset({ core, context, github, release });
- name: Publish Latest Release
uses: actions/github-script@v7
id: publish_latest_release
with:
script: |
const scriptPath = '${{ github.workspace }}/.github/scripts/publish-latest-release.js';
const release = ${{ steps.retrieve_latest_release.outputs.release }};
const { default: publishLatestRelease } = await import(scriptPath);
await publishLatestRelease({ core, context, github, release });
deploy:
name: Deploy Application
runs-on: ubuntu-latest
timeout-minutes: 30
needs: [release]
if: github.ref_name == 'main' || github.ref_name == 'dev'
env:
node_version: 20.x
netlify_version: 17.13.2
environment:
name: netlify
url: ${{ steps.deploy_app.outputs.deployInfo.environmentUrl }}
steps:
- name: Checkout Repository ${{ github.event.repository.name }}
uses: actions/checkout@v4
- name: Setup Node Version ${{ env.node_version }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: "npm"
- name: Setup Netlify Version ${{ env.netlify_version }}
run: |
npm install -g netlify-cli@${{ env.netlify_version }}
npm install decompress
- name: Download Release Asset
uses: actions/github-script@v7
id: download_release_asset
with:
script: |
const scriptPath = '${{ github.workspace }}/.github/scripts/download-release-asset.cjs';
const { default: downloadReleaseAsset } = await import(scriptPath);
await downloadReleaseAsset({ core, context, github });
- name: Deploy Application
uses: actions/github-script@v7
id: deploy_app
with:
script: |
const scriptPath = '${{ github.workspace }}/.github/scripts/deploy-app-netlify.js';
const { default: deployApp } = await import(scriptPath);
const netlify = {
site: '${{ secrets.NETLIFY_SITE }}',
token: '${{ secrets.NETLIFY_TOKEN }}'
};
await deployApp({ core, exec, netlify });