Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use Node.js v20, bump deps, add CI jobs to build and audit #21

Merged
merged 4 commits into from
Sep 27, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
87 changes: 87 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: CI
on:
push:
branches:
- staging
pull_request:
branches:
- staging
workflow_dispatch:
schedule:
- cron: '12 0 1 * *' # At noon (UTC) on the first of the month

env:
node_version: '20.x'
FORCE_COLOR: 3

jobs:
build: # make sure build/ci work properly
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: npm
cache-dependency-path: '**/package-lock.json'

- name: npm ci
run: npm ci --prefer-offline

- name: npm run package
run: npm run package

- name: Check for any changed files
run: |
[[ -z $(git status --untracked-files=no --porcelain) ]] || \
(echo "::error title=npm run package::Files in the /dist directory shouldn't have changed. You forgot to run 'npm run package'." && exit 1)

audit:
name: Audit
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}

# We don't need to install deps to audit them

- name: npm audit
run: npm audit --audit-level=critical

lint:
name: Lint
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: ${{ env.node_version }}
cache: npm
cache-dependency-path: '**/package-lock.json'

- name: npm ci
run: npm ci --prefer-offline

- name: npm lint
run: npm run lint

test:
name: Test
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Send Teams notification
uses: ./
with:
status: ${{ job.status }}
webhook-url: ${{ secrets.MS_TEAMS_WEBHOOK_URL }}
# We need to manually check the notification
6 changes: 3 additions & 3 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,12 @@ jobs:
security-events: write
steps:
- name: Checkout repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Initialize CodeQL
uses: github/codeql-action/init@v2
uses: github/codeql-action/init@v3
with:
languages: javascript

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v2
uses: github/codeql-action/analyze@v3
43 changes: 0 additions & 43 deletions .github/workflows/test.yml

This file was deleted.

2 changes: 1 addition & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,5 @@ inputs:
# https://learn.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook#create-an-incoming-webhook
required: true
runs:
using: 'node16'
using: 'node20'
main: 'dist/index.js'
10 changes: 3 additions & 7 deletions dist/index.js

Large diffs are not rendered by default.

9 changes: 0 additions & 9 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,15 +1,6 @@
const { getInput, setFailed, info } = require('@actions/core')
const github = require('@actions/github')

// Polyfill fetch for Node.js 16
if (!global.fetch) {
const nodeFetch = require('node-fetch')
global.fetch = nodeFetch
global.Headers = nodeFetch.Headers
global.Request = nodeFetch.Request
global.Response = nodeFetch.Response
}

// TODO: Use GitHub's icons (primer/octicons), which will require converting and colorizing the SVGs
function getImageUrl (status) {
switch (status) {
Expand Down
Loading