This repository contains GitHub Actions maintained by the Elastic Organization. Each action lives in its own top-level directory.
Additional actions can be added as new top-level directories.
Actions in this repository are consumed with the standard subdirectory syntax:
uses: elastic/github-actions/<action-name>@<ref>Examples:
steps:
- uses: elastic/github-actions/litellm-token@v2.1.1steps:
- uses: elastic/github-actions/litellm-token@f443b600d91635bebf5b0d9ebc620189c0d6fba5 # v2.1.1The @<ref> portion is always a repository ref. That means a tag, branch, or SHA points to a
commit in elastic/github-actions, and GitHub then loads the requested action directory from
that commit.
Because refs are repository-wide, action usage looks path-scoped but versioning is commit-scoped. In practice, this means:
elastic/github-actions/litellm-token@v2.1.1uses thelitellm-token/directory from the repo tagv2.1.1elastic/github-actions/another-action@v3.0.0would use theanother-action/directory from the repo tagv3.0.0- SHA pinning is supported and recommended when consumers want an immutable reference
Different actions in this repository can be referenced at different SHAs if needed:
jobs:
first_job:
runs-on: ubuntu-latest
steps:
- uses: elastic/github-actions/litellm-token@abc123 # v3.1.0
second_job:
runs-on: ubuntu-latest
steps:
- uses: elastic/github-actions/action-two@def456 # v3.0.0The root toolchain uses pnpm (see packageManager in package.json for exact version). Use a Node.js version that matches engines.node, enable Corepack, then install and run scripts from the repository root:
corepack enable
pnpm installRepository scripts in scripts/ are authored in TypeScript and run with tsx. They are covered by the standard root checks:
pnpm typecheckfor script typechecking and editor-friendly TS supportpnpm lintforoxlintpnpm testfor Vitest coveragepnpm buildto executescripts/build-actions.ts
New actions should be created as top-level directories. A minimal example looks like this:
my-action/
action.yml
src/
index.ts
pre.ts # optional
post.ts # optional
dist/
index.js
pre.js # generated when src/pre.ts exists
post.js # generated when src/post.ts exists
licenses.txt
Example action.yml:
name: My Action
description: Example action layout for this repository
runs:
using: node24
main: dist/index.js
pre: dist/pre.js
post: dist/post.jsExample usage after release:
steps:
- uses: elastic/github-actions/my-action@v1The important part is that dist/ is committed before release so consumers can run the action
directly from the repository ref they pin to. In this repository, dist/ is treated as a generated
artifact:
- Pull requests are reviewed as source changes and must build successfully.
- Trusted same-repo
release/**pull requests that bump the rootpackage.jsonversion auto-update committeddist/output on each push. masterauto-updates committeddist/output after merges.- Releases rebuild and fail if a fresh build would change committed output, so release tags always
point to commits with up-to-date
dist/.
CI installs dependencies with pnpm install --frozen-lockfile, so changes that require lockfile
updates must include an updated pnpm-lock.yaml.
The build treats any top-level directory that contains an action.yml as an action and builds it with @vercel/ncc.
Build assumptions for root-managed actions:
src/index.tsis required and always builds todist/index.jssrc/pre.tsis optional and, when present, builds todist/pre.jssrc/post.tsis optional and, when present, builds todist/post.jspnpm builddeletes each action's existingdist/directory before rebuilding generated outputdist/licenses.txtis generated from the main bundle build
If an action declares JavaScript lifecycle hooks in action.yml, they should follow the same output convention:
runs:
using: node24
main: dist/index.js
pre: dist/pre.js
post: dist/post.jsThe root package.json version is the release source of truth for this repository.
To prepare a release:
- Open a same-repo pull request with a branch in the form of
release/**that bumps the rootpackage.jsonversionfield. - Let CI auto-update committed
dist/output on the release pull request as you push changes. - Merge the pull request to
master.
After merge, the release workflow:
- reads the merged package version and creates the matching
vX.Y.Ztag - generates release notes automatically with GitHub
- uses
.github/release.ymllabels and categories to section the release page - force-updates the floating major tag (for example
v3)