[Snyk] Security upgrade node from 20.5.1-alpine3.18 to 20.11.1-alpine3.18 #138
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
name: CI, with security check using Snyk | |
# Controls when the workflow will run | |
on: | |
# Triggers the workflow on push or pull request events but only for the main branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
# A workflow run is made up of one or more jobs that can run sequentially or in parallel | |
jobs: | |
security: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@master | |
- name: Run Snyk to check for vulnerabilities | |
uses: snyk/actions/node@master | |
# continue-on-error: true | |
env: | |
SNYK_TOKEN: ${{ secrets.SNYK_TOKEN }} | |
with: | |
command: test | |
build: | |
needs: security | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
node-version: [16.x, 18.x, 20.x] | |
steps: | |
# Checks-out your repository under $GITHUB_WORKSPACE, so your job can access it | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
- run: npm run build --if-present | |
- run: npm test | |
deploy_github_pages: | |
needs: build | |
runs-on: ubuntu-latest | |
env: | |
GITHUB_PAGES_REPO: adafycheng/adafycheng.github.io | |
GITHUB_PAGES_PATH: github_pages | |
strategy: | |
matrix: | |
node-version: [20.x] | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Use Node.js ${{ matrix.node-version }} | |
uses: actions/setup-node@v3 | |
with: | |
node-version: ${{ matrix.node-version }} | |
- name: Install dependencies | |
run: npm ci | |
- run: npm run build --if-present | |
- name: Check out from GitHub Pages | |
uses: actions/checkout@v3 | |
with: | |
repository: ${{ env.GITHUB_PAGES_REPO }} | |
token: ${{ secrets.ACTIONS_GITHUB_TOKEN }} | |
path: ${{ env.GITHUB_PAGES_PATH }} | |
ref: 'main' | |
- name: Copy files to GitHub Pages repo | |
run: | | |
rm ./$GITHUB_PAGES_PATH/static/css/* | |
rm ./$GITHUB_PAGES_PATH/static/js/* | |
cp -rf build/* ./$GITHUB_PAGES_PATH | |
- name: Commit and Push to GitHub Pages | |
run: | | |
# Exrtract Application Version | |
APP_VERSION=`cat package.json | jq -r '.version'` | |
echo "APP_VERSION: $APP_VERSION" | |
# Commit and Push | |
cd $GITHUB_PAGES_PATH | |
git config user.name "GitHub Actions Bot" | |
git config user.email "${{ secrets.ACTIONS_GITHUB_EMAIL }}" | |
git switch -c "v$APP_VERSION" | |
git add . | |
git commit -m "Deploy $APP_VERSION" | |
git push origin "v$APP_VERSION" | |