Skip to content

Commit

Permalink
ci: update github workflows
Browse files Browse the repository at this point in the history
- implement the harden-runner
- use the newest versions and set the commit hashes for the actions
- add commitlint action
  • Loading branch information
rweich committed Mar 23, 2024
1 parent 969c560 commit c9f4b44
Show file tree
Hide file tree
Showing 6 changed files with 241 additions and 75 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/build-test-versions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,21 +4,37 @@ on: [ push, pull_request ]

jobs:
build:
name: build/test on node versions

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [ 14.x, 16.x, 17.x ]
node-version: [ 18.x, 20.x, 21.x ]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v2
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
registry.yarnpkg.com:443
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1

- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v2
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # 4.0.1
with:
node-version: ${{ matrix.node-version }}
- run: yarn install

- run: yarn install --frozen-lockfile
- run: yarn type-check
- run: yarn lint
- run: yarn lint-tests
Expand Down
77 changes: 29 additions & 48 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
@@ -1,65 +1,46 @@
# For most projects, this workflow file will not need changing; you simply need
# to commit it to your repository.
#
# You may wish to alter this file to override the set of languages analyzed,
# or to provide custom queries or build logic.
#
# ******** NOTE ********
# We have attempted to detect the languages in your repository. Please check
# the `language` matrix defined below to confirm you have the correct set of
# supported CodeQL languages.
#
name: "CodeQL"

on:
push:
# Dependabot triggered push events have read-only access, but uploading code scanning requires write access.
branches-ignore: [dependabot/**]
branches: [ "main" ]
pull_request:
branches: [ "main" ]

jobs:
analyze:
name: Analyze
name: CodeQL-Analyze
runs-on: ubuntu-latest
timeout-minutes: 360
permissions:
actions: read
contents: read
security-events: write

strategy:
fail-fast: false
matrix:
language: [ 'javascript' ]
language: [ 'javascript-typescript' ]

steps:
- name: Checkout repository
uses: actions/checkout@v2

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
# By default, queries listed here will override any specified in a config file.
# Prefix the list here with "+" to use these queries and those in the config file.
# queries: ./path/to/local/query, your-org/your-repo/queries@main

# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl

# ✏️ If the Autobuild fails above, remove it and uncomment the following three lines
# and modify them (or add more) to build your code if your project
# uses a compiled language

#- run: |
# make bootstrap
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
egress-policy: audit
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
uploads.github.com:443
- name: Checkout repository
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1

- name: Initialize CodeQL
uses: github/codeql-action/init@v3
with:
languages: ${{ matrix.language }}

- name: Autobuild
uses: github/codeql-action/autobuild@v3

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v3
with:
category: "/language:${{matrix.language}}"
32 changes: 32 additions & 0 deletions .github/workflows/commitlint.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Lint Commit Messages

on:
pull_request:
push:
branches-ignore: [main]

jobs:
commitlint:
if: github.actor != 'dependabot[bot]'

runs-on: ubuntu-latest

steps:
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
with:
fetch-depth: 0

- name: Lint
uses: wagoid/commitlint-github-action@0d749a1a91d4770e983a7b8f83d4a3f0e7e0874e # 5.4.4
with:
configFile: package.json
failOnWarnings: true
72 changes: 64 additions & 8 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,20 +2,76 @@ name: Release

on: workflow_dispatch

permissions:
contents: write

jobs:
release:

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
disable-sudo: true
egress-policy: audit
allowed-endpoints: >
api.github.com:443
github.com:443
registry.npmjs.org:443
registry.yarnpkg.com:443
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1
with:
persist-credentials: false
token: ${{ secrets.SEMANTIC_RELEASE_PAT }}

- name: Install Node
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # 4.0.1
with:
node-version: 18

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Build package
run: yarn build

- name: Semantic Release
uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # 4.0.0
id: semantic
with:
node-version: 16
- run: yarn install
- run: yarn build
- name: Release
semantic_version: 22
branch: main
extends: |
@rweich/semantic-release-config@3
extra_plugins: |
@semantic-release/changelog@6
@semantic-release/git@10
conventional-changelog-conventionalcommits@7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GITHUB_TOKEN: ${{ secrets.SEMANTIC_RELEASE_PAT }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: yarn semantic-release --branches main

- name: Outputs
run: |
cat <<EOO >> $GITHUB_STEP_SUMMARY
---
### Semantic release output
<table>
<tr><th>published</th><td>${{ steps.semantic.outputs.new_release_published }}</td></tr>
<tr><th>last release</th><td>${{ steps.semantic.outputs.last_release_version }}</td></tr>
<tr><th>next release</th><td>${{ steps.semantic.outputs.new_release_version }}</td></tr>
</table>
---
#### Release-Notes
${{ steps.semantic.outputs.new_release_notes }}
---
EOO
41 changes: 34 additions & 7 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,15 +4,42 @@ on: [ push, pull_request ]

jobs:
build:
name: Build
name: Build Test Coeverage

runs-on: ubuntu-latest

steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
api.github.com:443
github.com:443
objects.githubusercontent.com:443
nodejs.org:443
registry.npmjs.org:443
registry.yarnpkg.com:443
api.codecov.io:443
cli.codecov.io:443
storage.googleapis.com:443
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1

- name: Install Node
uses: actions/setup-node@b39b52d1213e96004bfcb1c61a8a6fa8ab84f3e8 # 4.0.1
with:
node-version: 16
- run: yarn install
- run: yarn test-coverage
- uses: codecov/codecov-action@v1
node-version: 18

- name: Install dependencies
run: yarn install --frozen-lockfile

- name: Run Test with coverage
run: yarn test-coverage

- name: Create coverage report
uses: codecov/codecov-action@54bcd8715eee62d40e33596ef5e8f0f48dbbccab # 4.1.0
with:
directory: ./coverage/
token: ${{ secrets.CODECOV_TOKEN }}
70 changes: 62 additions & 8 deletions .github/workflows/test-release.yml
Original file line number Diff line number Diff line change
@@ -1,23 +1,77 @@
name: Test-Release

on: [ push ]
on:
push:
branches-ignore: [dependabot/**]
workflow_dispatch:

permissions:
contents: write

jobs:
release:
name: test release

runs-on: ubuntu-latest

steps:
- uses: step-security/harden-runner@63c24ba6bd7ba022e95695ff85de572c04a18142 # 2.7.0
with:
disable-sudo: true
egress-policy: block
allowed-endpoints: >
github.com:443
registry.npmjs.org:443
- name: Get branch name
uses: tj-actions/branch-names@6871f53176ad61624f978536bbf089c574dc19a2 # 8.0.1
id: branch-name
uses: tj-actions/branch-names@v5
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
- name: Got branch name
run: |
cat <<EOO >> $GITHUB_STEP_SUMMARY
---
### 🌿 Running on branch: ${{ steps.branch-name.outputs.current_branch }}
---
EOO
- name: Checkout
uses: actions/checkout@b4ffde65f46336ab88eb53be808477a3936bae11 # 4.1.1

- name: Semantic Release
uses: cycjimmy/semantic-release-action@61680d0e9b02ff86f5648ade99e01be17f0260a4 # 4.0.0
id: semantic
with:
node-version: 16
- run: yarn install
- name: Release Test
dry_run: true
semantic_version: 22
branch: ${{ steps.branch-name.outputs.current_branch }}
extends: |
@rweich/semantic-release-config@3
extra_plugins: |
@semantic-release/changelog@6
@semantic-release/git@10
conventional-changelog-conventionalcommits@7
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
run: yarn semantic-release --dry-run --branches ${{ steps.branch-name.outputs.current_branch }}

- name: Test Outputs
run: |
cat <<EOO >> $GITHUB_STEP_SUMMARY
---
### Semantic release output (DRY-RUN)
<table>
<tr><th>published</th><td>${{ steps.semantic.outputs.new_release_published }}</td></tr>
<tr><th>last release</th><td>${{ steps.semantic.outputs.last_release_version }}</td></tr>
<tr><th>next release</th><td>${{ steps.semantic.outputs.new_release_version }}</td></tr>
</table>
---
#### Release-Notes
${{ steps.semantic.outputs.new_release_notes }}
---
EOO

0 comments on commit c9f4b44

Please sign in to comment.