Update dependency upgrades - non-major (#288) #108
This file contains hidden or 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: Lint, Check Types, Build, Deploy to Fly.io | |
on: push | |
jobs: | |
ci: | |
name: Lint, Check Types, Build | |
runs-on: ubuntu-latest | |
env: | |
PGHOST: localhost | |
PGDATABASE: security_vulnerability_examples | |
PGUSERNAME: security_vulnerability_examples | |
PGPASSWORD: security_vulnerability_examples | |
steps: | |
- name: Start preinstalled PostgreSQL on Ubuntu | |
run: | | |
sudo systemctl start postgresql.service | |
pg_isready | |
- name: Create database user | |
run: | | |
sudo -u postgres psql --command="CREATE USER security_vulnerability_examples PASSWORD 'security_vulnerability_examples'" --command="\du" | |
- name: Create database and allow user | |
run: | | |
sudo -u postgres createdb --owner=security_vulnerability_examples security_vulnerability_examples | |
- uses: actions/checkout@v4 | |
- uses: pnpm/action-setup@v4 | |
- uses: actions/setup-node@v4 | |
with: | |
node-version: 'lts/*' | |
cache: 'pnpm' | |
# Install dependencies for node-canvas to avoid errors like this | |
# while building from source: | |
# | |
# ``` | |
# .../canvas@3.1.0/node_modules/canvas install: Package pixman-1 was not found in the pkg-config search path. | |
# .../canvas@3.1.0/node_modules/canvas install: Perhaps you should add the directory containing `pixman-1.pc' | |
# .../canvas@3.1.0/node_modules/canvas install: to the PKG_CONFIG_PATH environment variable | |
# .../canvas@3.1.0/node_modules/canvas install: Package 'pixman-1', required by 'virtual:world', not found | |
# .../canvas@3.1.0/node_modules/canvas install: gyp: Call to 'pkg-config pixman-1 --libs' returned exit status 1 while in binding.gyp. while trying to load binding.gyp | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! configure error | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! stack Error: `gyp` failed with exit code: 1 | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! stack at ChildProcess.<anonymous> (/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@10.5.2/node_modules/pnpm/dist/node_modules/node-gyp/lib/configure.js:317:18) | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! stack at ChildProcess.emit (node:events:518:28) | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:293:12) | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! System Linux 6.8.0-1021-azure | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! command "/opt/hostedtoolcache/node/22.14.0/x64/bin/node" "/home/runner/setup-pnpm/node_modules/.pnpm/pnpm@10.5.2/node_modules/pnpm/dist/node_modules/node-gyp/bin/node-gyp.js" "rebuild" | |
# .../canvas@3.1.0/node_modules/canvas install: gyp ERR! cwd /home/runner/work/security-vulnerability-examples-next-js-postgres/security-vulnerability-examples-next-js-postgres/node_modules/.pnpm/canvas@3.1.0/node_modules/canvas | |
# ``` | |
# | |
# - https://github.com/Automattic/node-canvas/issues/1065#issuecomment-2691025715 | |
- name: Install dependencies for node-canvas | |
run: sudo apt-get install libcairo2-dev libpango1.0-dev | |
- name: Install dependencies | |
run: pnpm install | |
- run: pnpm migrate up | |
# Also generates next-env.d.ts, required for tsc | |
- name: Build Next.js app | |
run: pnpm build | |
env: | |
API_KEY: ${{ secrets.API_KEY }} | |
NODE_ENV: production | |
- name: Run TypeScript Compiler | |
run: pnpm tsc | |
- name: Run ESLint | |
run: pnpm eslint . --max-warnings 0 | |
env: | |
API_KEY: ${{ secrets.API_KEY }} | |
- name: Run Stylelint | |
run: pnpm stylelint '**/*.{css,scss,less,js,tsx}' | |
cd: | |
name: Deploy to Fly.io | |
runs-on: ubuntu-latest | |
needs: ci | |
if: github.ref == 'refs/heads/main' | |
env: | |
FLY_API_TOKEN: ${{ secrets.FLY_API_TOKEN }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: superfly/flyctl-actions/setup-flyctl@master | |
- run: flyctl deploy --remote-only |