A collection of GitHub actions for use within ottofeller
projects.
Provides the following functionality:
- Check out a repo
- Setting up a distribution of the requested Node.js version
- Install an app
- Run an npm script
- The dir to the app may be specified
The action sets up node, installs npm packages and runs a command supplied in inputs, see action.yml. See test-npm-run.yml for an example of the action usage.
NOTE: You do not need to check out the repo before running the action. Moreover if you do check it out, the result will be thrown away as the action checks out from a provided ref (with default branch as a fallback).
Basic:
steps:
- uses: ottofeller/github-actions/npm-run@main
with:
command: npm run test:all -- --verbose
Advanced:
steps:
- uses: ottofeller/github-actions/npm-run@main
with:
node-version: 16
registry-url: https://npm.pkg.github.com/
scope: @npmscope
directory: app
command: npm run test:all -- --verbose
The node-version
, registry-url
, scope
inputs are optional and are similar to those in the setup-node
action. The latter is used under the hood and the inputs are fed into setup action. See setup-node docs for details.
The directory
is optional and defaults to ./
.
The only required input is command
which is the command that will be run in bash
after installation of node and dependencies.
Provides the following functionality:
- Check out a repo
- Find the latest tag and bumps it with a new patch version
- Creates a draft release with the new tag
- Outputs ID of the created release
The action searches your repo for the most recent tag and creates a new one with patch update, then a draft release is created for the tag, see action.yml. See test-create-release.yml for an example of the action usage.
Basic:
steps:
- uses: ottofeller/github-actions/create-release@main
with:
initial-version: 0.0.1
release-branches: main,master,dev
bump-level: minor
github-token: ${{ secrets.GITHUB_TOKEN }}
Advanced:
steps:
- uses: ottofeller/github-actions/create-release@main
with:
initial-version: 0.0.1
release-branches: main,master,dev
bump-level: minor
github-token: ${{ secrets.GITHUB_TOKEN }}
update-main-package_json: true
update-children-path: |
packages/first
packages/second
packages/third
update-children-bump-level: |
minor
none
patch
initial-version
and release-branches
inputs are used in anothrNick/[email protected]
action and have similar semantics. See github-tag-action docs for details.
initial-version
is optional and defaults to0.0.1
release-branches
is a comma separated list of branches to create a release from, optional and defaults tomain
bump-level
is a level of version to bump which might be one ofmajor
,minor
,patch
and defaults topatch
github-token
is required and represents your GitHub token which is used for accessing the repo.update-root-package_json
is an optional flag that triggerspackage.json
version update in the root folder. Defaults tofalse
.update-children-path
is optional. Usesnpm version
command to update version inpackage.json
files within specified folders. Provide a space separated list of folder paths for each package.json file to be updated. Applies changes only ifupdate-children-bump-level
input is provided. Defaults to empty string which effectively passes the step.update-children-bump-level
is optional. A space separated list of version update attribute ofnpm-version
command to be used withupdate-children-path
input. Make sure the two lists match in length (for paths with missing values of bump-level no update will be performed). To skip updates for a package in the middle of the list passnone
. Note that a specific version may be provided instead of bump level. Defaults to empty string.
Note that the last three inputs create a new commit. update-children-path
and update-children-bump-level
work together but independent of update-root-package_json
.
- provide only
update-root-package_json: true
to bump the root package version and leave children as is; - provide
update-children-path
andupdate-children-bump-level
withoutupdate-root-package_json
to bump version of only the children packages and leave the root one as is; - provide the three inputs to update both root and children packages.
Obtains the commit hash of the latest release. It does:
- Search through git history and find the latest release (excluding prerelease and draft types).
- Exit with code 1 if no release was found.
- Output commit hash of the latest release if found.
The action searches your repo for the most recent release tag and outputs its commit hash, see action.yml. See test-latest-release-commit-hash.yml for an example of the action usage.
steps:
- id: commit-hash
uses: ottofeller/github-actions/latest-release-commit-hash@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ steps.commit-hash.outputs.commit_hash }}
jobs:
set-commit-hash:
runs-on: ubuntu-latest
outputs:
commit_hash: ${{ steps.commit-hash.outputs.commit_hash }}
steps:
- id: commit-hash
uses: ottofeller/github-actions/latest-release-commit-hash@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
lint:
needs: set-commit-hash
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
with:
fetch-depth: 0
ref: ${{ needs.set-commit-hash.outputs.commit_hash }}
- uses: ottofeller/github-actions/npm-run@main
with:
command: npm run lint
- Inputs:
github-token
is required and represents your GitHub token which is used for accessing the repo.
- Outputs:
commit_hash
is the commit hash of the latest release found in the repo.
Provides the following functionality:
- Check out a repo
- Setting up a distribution of the requested Node.js version
- Install dependencies
- Publishes the package to a specified registry
The action sets up node, installs dependencies and runs an npm publish
command, see action.yml. See test-publish-npm.yml for an example of the action usage.
Basic:
jobs:
...
publish-npm:
needs: [set-commit-hash, lint, test]
runs-on: ubuntu-latest
steps:
- uses: ottofeller/github-actions/publish-npm@main
with:
npm-token: ${{ secrets.NPM_TOKEN }}
Advanced:
jobs:
...
publish-npm:
needs: [set-commit-hash, lint, test]
runs-on: ubuntu-latest
steps:
- uses: ottofeller/github-actions/publish-npm@main
with:
ref: ${{ needs.set-commit-hash.outputs.commit_hash }}
node-version: 18
registry-url: https://npm.pkg.github.com/
scope: "@worldcoin"
npm-token: ${{ secrets.NPM_TOKEN }}
access: restricted
include-build-step: true
directory: packages/app
- The
node-version
,registry-url
,scope
inputs are optional and is similar tosetup-node
. The latter is used under the hood and the inputs are fed into setup action. See setup-node docs for details. By defaultnode-version
is set to 16. ref
is optional and represents the git reference used for publishing. Used in checkout action and has the same behavior: when checking out the repository that triggered a workflow, this defaults to the reference or SHA for that event; otherwise, uses the default branch.npm-token
is required and represents your NPM token which is used for access to the registry.access
is optional. It is used innpm publish
command and tells the registry whether this package should be published as public or restricted. Defaults to public.include-build-step
is an optional flag for running build script (npm run build
command) before publishing. Defaults tofalse
.dry-run
is an optional flag for running thenpm publish
command with--dry-run
option. Defaults tofalse
.directory
is optional and defaults to./
.
Provides the following functionality:
- Downloads mermerd tarball and extracts the executable
- Runs mermerd either with run config file or with
connectionString
CLI parameter - Checks for changes and commits the created/updated file to the repo
For detailed steps of the action see action.yml. See below for examples of the action usage.
NOTE: You do not need to check out the repo before running the action.
With run config:
steps:
- uses: ottofeller/github-actions/generate-db-diagram@main
with:
run-config: ./yourRunConfig.yaml
With connection string:
steps:
- uses: ottofeller/github-actions/generate-db-diagram@main
with:
connection-string: postgresql://user:password@localhost:5432/yourDb
Specify output filename:
steps:
- uses: ottofeller/github-actions/generate-db-diagram@main
with:
run-config: ./yourRunConfig.yaml
output-filename: diagram.mmd
Specify mermerd tarball URL:
steps:
- uses: ottofeller/github-actions/generate-db-diagram@main
with:
mermerd-tarball-url: https://github.com/KarnerTh/mermerd/releases/download/v0.3.0/mermerd_0.3.0_linux_amd64.tar.gz
run-config: ./yourRunConfig.yaml
output-filename: diagram.mmd
Specify schema and tables to use:
steps:
- uses: ottofeller/github-actions/generate-db-diagram@main
with:
connection-string: postgresql://user:password@localhost:5432/yourDb
schema: hollywood
tables: films,actors,awards
mermerd-tarball-url
is the URL to download mermerd executable from. Defaults tov0.4.1
asset stored on github.run-config
is the path to a run config file (YAML). If provided connection-string option is ignored.connection-string
is the connection string for the DB.schema
is the schema that should be used. Default tupublic
.tables
is a list of tables to include. Defaults to all tables.output-filename
is the output file name. Defaults toresult.mmd
. When using run config file make sure the output matches the default one o remember to provide the custom one with this option.
Runs spectaql
to get Introspection Query and generates static documentation for a GraphQL schema.
For detailed steps of the action see action.yml. See below for examples of the action usage.
NOTE: You do not need to check out the repo before running the action.
Only with an introspection-url:
steps:
- uses: ottofeller/github-actions/generate-graphql-docs@main
with:
introspection-url: https://server.graphql/introspect
With a custom config:
steps:
- uses: ottofeller/github-actions/generate-graphql-docs@main
with:
config-path: ./yourConfig.yaml
introspection-url: https://server.graphql/introspect
headers: ${{ format('{"x-access-token":"{0}"}', github.ACCESS_TOKEN) }}
target-dir: docs/graphql
config-path
is the path to a config file (YAML). Defaults to the config stored with the action. The latter sets only basic page info and no data for server querying. If you choose to use a custom config refer to the spectaql readme for a description of the file structure and examples.introspection-url
is the URL for an Introspection Query. Defaults tohttp://localhost:3000/
.headers
is an arbitrary set of headers for the Introspection Query as a JSON string. Empty by default.target-dir
is the output folder name. Defaults topublic
.
The scripts and documentation are not licensed. However the use is restricted to Ottofeller projects.