113 Commits
Author SHA1 Message Date
Max Schwenk d3603274ac Add no-cache option (#58) 2024-02-23 11:09:38 -08:00
Andy Palmer 0f37bd8169 Move cache save to runs.post and exit early (#60) 2024-02-16 14:14:07 -08:00
Filip Czaplicki 12944059f7 Fix typo in README.md (#57) 2024-02-09 18:03:04 +01:00
Ben Limmer 8642d99a51 docs: add --frozen-lockfile to README (#52)
Many folks will copy/paste the sample code from the README directly. In CI, most people will want to enforce a frozen lockfile.
2024-02-01 17:30:42 -08:00
Jacob Hummer 40646b1808 Add GitHub action to auto-update the v1 tag (#53)
Create release.yml
2024-02-01 17:29:22 -08:00
Paul Razvan Berg 94177e527c docs: add explanatory note about setup-node (#47) 2024-01-03 11:33:26 +01:00
autofix-ci[bot] 9b21598af8 [autofix.ci] apply automated fixes 2023-12-03 12:43:51 +00:00
Jozef Steinhübl (xHyroM) c7420ae597 release: 1.1.1 2023-12-03 13:43:25 +01:00
Jozef Steinhüblandautofix-ci[bot] c0059f0222 fix: package manager (#42)
* fix: read version from package json

* [autofix.ci] apply automated fixes

* Update index.ts

* Update action.yml

* [autofix.ci] apply automated fixes

* yarn does random things

* [autofix.ci] apply automated fixes

* ci: check if version from packageManager is actually 1.0.0

* ci: bash is not javascript

* ci: use  instead ::set-output

---------

Co-authored-by: autofix-ci[bot] <114827586+autofix-ci[bot]@users.noreply.github.com>
2023-12-03 13:42:54 +01:00
Jozef Steinhübl e900e6b108 release: 1.1 (#41)
* bump

* bump

* bump
2023-11-26 21:41:40 +01:00
Ashcon Partovi a93230df19 Various improvements and fixes to setup-bun (#40)
* Do not save cache on hit
* Support Windows (canary only)
* Support `registry-url` and `scope`
2023-11-17 15:58:17 -08:00
Vitor Gomes 830e319e28 Add auth setup for private registry with scope (#16)
feat: add auth setup to private registry with scope
2023-11-01 10:17:17 +01:00
Dan Adajian 6be87460e3 feat: support packageManager in package.json (#27) 2023-10-25 15:13:22 +02:00
CyberFlame bd26ebd2c7 build: bump nodejs to v20 (#24)
update to use nodejs as per planned deprecation of node16

https://github.blog/changelog/2023-09-22-github-actions-transitioning-from-node-16-to-node-20/
2023-09-26 17:36:38 +02:00
Ashcon Partovi a1800f471a Fix missing diff 2023-09-11 13:55:59 -07:00
Ashcon Partovi 5da0b0b067 Remove node_modules, for real 2023-09-11 12:52:41 -07:00
Ashcon Partovi c34bee2511 Fix bunx (#18)
* Add symlink for bunx

* Remove node_modules, use bundled code instead

* Add revision support
2023-09-11 12:37:45 -07:00
Nilesh Suthar 67e559db2c fix: use copy instead of mv (#15)
* fix: use copy instead of mv

* fix: path does not exist
2023-09-07 19:46:23 +02:00
Ashcon Partovi 4573031972 Do not cache action releases 2023-03-01 17:36:06 -08:00
Ashcon Partovi 1c8c9a7615 Fix encoding bug with 'action:<number>' version 2023-03-01 16:49:16 -08:00
Ashcon Partovi 13974bf408 Document usage of action downloads 2023-03-01 16:01:35 -08:00
Ashcon Partovi 157143337b Make cacheHit conform to best practices for actions 2023-03-01 15:58:31 -08:00
Ashcon Partovi c7179230d0 Merge pull request #7 from oven-sh/v1-pre
Next release of setup-bun
2023-02-22 18:21:07 -08:00
Ashcon Partovi 15050a7632 Actually fix double zip issue 2023-02-22 18:19:00 -08:00
Ashcon Partovi a730821cf4 Fix double zip issue? 2023-02-22 18:11:20 -08:00
Ashcon Partovi 8c368db359 Add debug statements 2023-02-22 18:05:23 -08:00
Ashcon Partovi 41bc2e859b Do not fail-fast for action 2023-02-22 17:57:41 -08:00
Ashcon Partovi 3c2d6a32bd Use newer checkout 2023-02-22 17:56:01 -08:00
Ashcon Partovi 3f252a86a6 Fix not being added to path 2023-02-22 17:51:12 -08:00
Ashcon Partovi 9c14b74b45 Next release of setup-bun 2023-02-22 17:47:24 -08:00
Colin McDonnell ed9eb0969c chore: update artifact URL 2023-01-13 12:06:42 -08:00
Colin McDonnell 91e57dc649 chore: update artifact URL 2023-01-13 12:00:19 -08:00
Hyro 37c5fa5bfd docs: change actions owner 2023-01-12 09:00:20 +01:00
xHyroM 29cb413d63 feat: update dependencies, node 2022-10-29 10:03:51 +02:00
xHyroM 0ec953ee6d chore(README): bump version 2022-07-28 09:26:39 +02:00
xHyroM 21ca0e24af chore: bump version 2022-07-28 09:25:52 +02:00
xHyroM 673843c5ea fix: extract two times for custom urls 2022-07-28 09:19:57 +02:00
xHyroM 38a9038faf fix: extract two times for custom urls 2022-07-28 09:19:39 +02:00
xHyroM 1e0686b2cc fix: extract two times for custom urls 2022-07-28 09:18:51 +02:00
xHyroM a11484a419 chore: dont cache if customDownloadUrl 2022-07-28 09:12:02 +02:00
xHyroM fe160cf381 chore: debug 2022-07-28 08:44:36 +02:00
xHyroM dbb8e61d45 chore: debug 2022-07-28 08:42:43 +02:00
xHyroM a99ac77932 chore: build 2022-07-28 08:39:58 +02:00
xHyroM fe4b2b1cd6 chore: build 2022-07-28 08:39:00 +02:00
xHyroM 10e847eceb fix: im idiot.... 2022-07-28 08:37:15 +02:00
xHyroM b3fb4f3421 chore: debug 2022-07-28 08:35:10 +02:00
xHyroM f5a14b237f chore: debug 2022-07-28 08:31:07 +02:00
xHyroM e2c23afd2e chore: debug 2022-07-28 08:27:22 +02:00
xHyroM befdce7132 chore: debug 2022-07-28 08:27:11 +02:00
xHyroM 3c39374369 chore: debug 2022-07-28 08:26:28 +02:00
xHyroM 3e21e45aa4 chore: debug 2022-07-28 08:24:56 +02:00
xHyroM 3b03c8d63a chore: debug 2022-07-28 08:21:33 +02:00
xHyroM bc3424761e chore: debug 2022-07-28 08:21:25 +02:00
xHyroM 962df21a50 chore: debug 2022-07-28 08:16:10 +02:00
xHyroM c3404c3d6b chore(workflows/test): use ACCESS_TOKEN 2022-07-28 08:10:27 +02:00
xHyroM f391a17228 chore: use api.github.com 2022-07-28 08:06:06 +02:00
xHyroM 24c8fd036a fix: add token to install 2022-07-28 08:01:15 +02:00
xHyroM 89f6825456 fix: add token to install 2022-07-28 07:59:44 +02:00
xHyroM 079e10bfd6 fix(getGithubRelease): missing .zip 2022-07-28 07:54:35 +02:00
xHyroM 3532147424 fix: missing .js 2022-07-28 07:53:26 +02:00
xHyroM e6a8865f72 feat: custom download url, custom repository 2022-07-28 07:50:56 +02:00
Hyro 27a94d6f80 chore(action): fix 2022-07-27 08:20:47 +02:00
Hyro b0a04f5fb3 chore: bump version 2022-07-27 08:18:45 +02:00
Hyro ddba6331f8 chore: bump version 2022-07-27 08:18:27 +02:00
Hyro 99221c1ae0 fix(action): add github.token as default 2022-07-27 08:18:12 +02:00
Hyro 13923243f4 chore(README): add github token 2022-07-26 07:29:31 +02:00
xHyroM a9318b00d5 chore(test): update 2022-07-25 22:48:11 +02:00
xHyroM bf40fde936 chore(test): update 2022-07-25 22:36:22 +02:00
xHyroM 92c5bc2cef chore(test): add canary 2022-07-25 22:32:15 +02:00
xHyroM 37397a08ec feat: canary support 2022-07-25 22:31:43 +02:00
xHyroM a0f9c413e5 chore(workflows): update test 2022-07-16 18:53:20 +02:00
xHyroM d744239ce1 chore(workflows): update test 2022-07-16 18:52:25 +02:00
xHyroM bfac95679f chore(workflows): update test 2022-07-16 18:50:53 +02:00
xHyroM 640630d09e chore: bump version 2022-07-16 18:48:17 +02:00
xHyroM 70b6cfe9d1 chore: build 2022-07-16 18:47:40 +02:00
Hyro 933334b350 fix(getGithubRelease): correct token pass 2022-07-16 18:46:00 +02:00
Hyro c52f1f18be chore: new example 2022-07-13 09:42:54 +02:00
Hyro 08cc23c06e chore: bump version 2022-07-13 09:42:16 +02:00
Hyro baf23f03bc chore: bump version 2022-07-13 09:42:02 +02:00
Hyro 3868f53a52 chore(CI): fix workflow 2022-07-13 07:50:55 +02:00
xHyroM 627e67fd7b chore(CI): update test 2022-07-13 07:04:23 +02:00
xHyroM 62d40e4bee chore(CI): update test 2022-07-12 22:08:16 +02:00
xHyroM e838800258 chore(CI): change job status 2022-07-12 19:58:24 +02:00
xHyroM 37657f4f9f fix: dont fail 2022-07-12 19:56:32 +02:00
xHyroM 633e7abe1e fix: dont error when invalid asset for miscTestBuilds 2022-07-12 19:53:24 +02:00
xHyroM 4e76ddea17 fix: warn if bad version 2022-07-12 18:53:38 +02:00
xHyroM 5a78c10e01 fix: verion.trim is not function 2022-07-12 18:46:22 +02:00
xHyroM 6dae544af4 fix: correct repo for misc test builds 2022-07-12 18:43:56 +02:00
xHyroM 054bb2f631 chore: build 2022-07-12 18:42:27 +02:00
xHyroM 9f7c2a5c23 feat: add support for test builds 2022-07-12 18:39:58 +02:00
xHyroM 81ecfb54f4 chore: update package.json, license 2022-07-12 11:03:29 +02:00
xHyroM 55fec52d7e chore: bump version 2022-07-12 09:59:54 +02:00
xHyroM b66dd1b4a1 chore(CI): cleanup 2022-07-12 09:59:17 +02:00
xHyroM f4ba16032c chore(CI): test mac 2022-07-12 09:57:54 +02:00
xHyroM a440f657d6 chore(CI): test mac 2022-07-12 09:56:12 +02:00
xHyroM 9cb3b94a9d chore(CI): test mac 2022-07-12 09:54:37 +02:00
xHyroM 9fb3c0c9e9 feat: use homedir from os 2022-07-12 09:39:16 +02:00
xHyroM 20a5153038 chore: debug 2022-07-12 09:34:11 +02:00
xHyroM e24995197a chore: debug 2022-07-12 09:31:35 +02:00
xHyroM 5ae94929ee chore: fix workflow 2022-07-12 09:29:37 +02:00
xHyroM bf0dbd9f81 chore: remove debugging, build 2022-07-12 09:29:03 +02:00
xHyroM 9bbc376c40 chore: build 2022-07-12 09:25:05 +02:00
xHyroM 09d3724d34 chore: build 2022-07-12 09:23:33 +02:00
xHyroM c35af372da fix: install 2022-07-12 09:16:35 +02:00
xHyroM 36bc669fea fix: use asset.name 2022-07-12 09:13:40 +02:00
xHyroM 32f942a87d chore: build 2022-07-12 09:11:55 +02:00
xHyroM 2af2463ea8 chore: debug 2022-07-12 09:11:41 +02:00
xHyroM c8d57cdc66 chore: build 2022-07-12 09:10:45 +02:00
xHyroM 8251de54ce fix: add path 2022-07-12 09:09:40 +02:00
xHyroM 19350f2b4f chore(test): add workflow dispatch 2022-07-12 09:08:38 +02:00
xHyroM 16e8c96a41 feat: add @actions/cache 2022-07-12 09:00:22 +02:00
xHyroM b15fb7d098 chore: build 2022-07-12 08:40:58 +02:00
xHyroM ad6ee5950c feat: clean version 2022-07-12 08:39:36 +02:00
460 changed files with 1249 additions and 1121511 deletions
+1
View File
@@ -0,0 +1 @@
dist/**/* linguist-generated=true
+30
View File
@@ -0,0 +1,30 @@
name: autofix.ci # Must be named this for autofix.ci to work
on:
workflow_dispatch:
pull_request:
push:
branches:
- main
permissions:
contents: read
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Install Dependencies
run: npm install
- name: Format
run: |
npm run format
npm run build
- name: Commit
uses: autofix-ci/action@d3e591514b99d0fca6779455ff8338516663f7cc
+25
View File
@@ -0,0 +1,25 @@
name: Release new action version
on:
release:
types: [released]
workflow_dispatch:
inputs:
TAG_NAME:
description: 'Tag name that the major tag will point to'
required: true
env:
TAG_NAME: ${{ github.event.inputs.TAG_NAME || github.event.release.tag_name }}
jobs:
update_tag:
runs-on: ubuntu-latest
permissions:
contents: write
steps:
- uses: actions/checkout@v3
- uses: actions/[email protected]
with:
source-tag: ${{ env.TAG_NAME }}
+64 -14
View File
@@ -1,28 +1,78 @@
name: test
name: Test
on:
push:
branches: [main]
workflow_dispatch:
pull_request:
branches: [main]
push:
branches:
- main
permissions:
contents: read
jobs:
test:
setup-bun:
runs-on: ${{ matrix.os }}
continue-on-error: true
strategy:
matrix:
os: [ubuntu-latest, macos-latest]
include:
- os: windows-latest
bun-version: canary
os:
- ubuntu-latest
- macos-latest
bun-version:
["latest", "0.1.2"]
- latest
- canary
- "0.8.1" # last version before 1.0
- "0.x"
- "1.0.0"
- "1.x"
- "1"
- "> 1.0.0"
- "< 2"
# Disable <sha> support for now. This is because Github Artifacts
# expire after 90 days, and we don't have another source of truth yet.
# - "822a00c4d508b54f650933a73ca5f4a3af9a7983" # 1.0.0 commit
steps:
- uses: actions/checkout@v2
- name: Checkout
uses: actions/checkout@v4
- name: Setup Bun
uses: ./
with:
bun-version: ${{ matrix.bun-version }}
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Try bun
run: bun add types
- name: Run Bun
run: |
bun --version
setup-bun-from-package-json-version:
runs-on: ${{ matrix.os }}
strategy:
matrix:
os:
- ubuntu-latest
- macos-latest
packageManager:
- [email protected]
- yarn@[email protected]
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Setup package.json
run: |
echo "$(jq '. += {"packageManager": "${{ matrix.packageManager }}"}' package.json)" > package.json
- name: Setup Bun
uses: ./
- name: Run Bun
id: bun
run: |
bun --version
echo "version=$(bun --version)" >> $GITHUB_OUTPUT
- name: Check version
run: |
if [[ "${{ steps.bun.outputs.version }}" == "1.0.0" ]]; then
echo "Version is 1.0.0"
else
echo "Expected version to be 1.0.0, got ${{ steps.bun.outputs.version }}"
exit 1
fi
+3
View File
@@ -0,0 +1,3 @@
.DS_Store
node_modules/
+1 -1
View File
@@ -1,6 +1,6 @@
MIT License
Copyright (c) 2019 David Frank
Copyright (c) 2022 Jozef Steinhübl
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
+36 -8
View File
@@ -1,22 +1,50 @@
# setup-bun
> Huge inspiration [setup-deno](https://github.com/denoland/setup-deno)
Set up your GitHub Actions workflow with a specific version of Bun.
Download, install, and setup [Bun](https://bun.sh) in GitHub Actions.
## Usage
### Latest stable
```yaml
- uses: xhyrom/setup-bun@v0.1.0
- uses: oven-sh/setup-bun@v1
with:
bun-version: latest
```
### Specific version
### Using a custom NPM registry
```yaml
- uses: xhyrom/setup-bun@v0.1.0
- uses: oven-sh/setup-bun@v1
with:
bun-version: "0.1.2"
registry-url: "https://npm.pkg.github.com/"
scope: "@foo"
```
If you need to authenticate with a private registry, you can set the `BUN_AUTH_TOKEN` environment variable.
```yaml
- name: Install Dependencies
env:
BUN_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
run: bun install --frozen-lockfile
```
### Node.js not needed
In most cases, you shouldn't need to use the [setup-node](https://github.com/actions/setup-node) GitHub Action.
## Inputs
| Name | Description | Default | Examples |
| -------------- | -------------------------------------------------- | ----------- | ------------------------------- |
| `bun-version` | The version of Bun to download and install. | `latest` | `canary`, `1.0.0`, `1.0.x` |
| `registry-url` | Registry URL where some private package is stored. | `undefined` | `"https://npm.pkg.github.com/"` |
| `scope` | Scope for private packages. | `undefined` | `"@foo"`, `"@orgname"` |
| `no-cache` | Disable caching of the downloaded executable. | `false` | `true`, `false` |
## Outputs
| Name | Description | Example |
| -------------- | ------------------------------------------ | ---------------- |
| `cache-hit` | If the Bun executable was read from cache. | `true` |
| `bun-version` | The output from `bun --version`. | `1.0.0` |
| `bun-revision` | The output from `bun --revision`. | `1.0.0+822a00c4` |
+27 -16
View File
@@ -1,22 +1,33 @@
name: "Setup Bun"
description: "Setup Bun by installing, downloading, and adding it to the path"
author: "xHyroM"
name: Setup Bun
description: Download, install, and setup Bun to your path.
author: robobun
branding:
icon: "play-circle"
color: "white"
icon: play-circle
color: white
inputs:
bun-version:
description: "The Bun version to install."
default: "latest"
github-token:
description: "The github token secret can be passed in using {{ secrets.GITHUB_TOKEN }}"
description: 'The version of Bun to install. (e.g. "latest", "canary", "1.0.0", "1.0.x", <sha>)'
required: false
registry-url:
required: false
description: "The URL of the package registry to use for installing Bun. Set the $BUN_AUTH_TOKEN environment variable to authenticate with the registry."
scope:
required: false
description: "The scope for authenticating with the package registry."
no-cache:
required: false
type: boolean
default: false
description: "Disable caching of bun executable."
outputs:
bun-version:
description: "The Bun version that was installed."
description: The version of Bun that was installed.
bun-revision:
description: The revision of Bun that was installed.
cache-hit:
description: If the version of Bun was cached.
runs:
using: "node12"
main: "dist/index.js"
using: "node20"
main: "dist/setup/index.js"
post: "dist/cache-save/index.js"
post-if: success()
BIN
View File
Binary file not shown.
Generated Vendored
+68
View File
File diff suppressed because one or more lines are too long
Generated Vendored
-25
View File
@@ -1,25 +0,0 @@
import { getInput, info, setFailed, setOutput } from '@actions/core';
import getGithubRelease from './utils/getGithubRelease.js';
import install from './utils/install.js';
const exit = (error) => {
setFailed(error);
process.exit();
};
const main = async () => {
try {
const version = getInput('bun-version');
const token = getInput('github-token');
if (!version)
return exit('Invalid bun version.');
const release = await getGithubRelease(version, token);
if ((release === null || release === void 0 ? void 0 : release.message) === 'Not Found')
return exit('Invalid bun version.');
info(`Going to install release ${release.tag_name}`);
await install(release);
setOutput('bun-version', release.tag_name);
}
catch (e) {
exit(e);
}
};
main();
Generated Vendored
+69
View File
File diff suppressed because one or more lines are too long
Generated Vendored
-28
View File
@@ -1,28 +0,0 @@
export default (assets) => {
let arch;
switch (process.arch) {
case 'arm64':
arch = 'aarch64';
break;
case 'x64':
arch = 'x64';
break;
default:
throw new Error(`Unsupported architechture ${process.arch}.`);
}
let platform;
switch (process.platform) {
case 'linux':
platform = 'linux';
break;
case 'darwin':
platform = 'darwin';
break;
default:
throw new Error(`Unsupported platform ${process.platform}.`);
}
return {
name: `bun-${platform}-${arch}.zip`,
asset: assets.find(asset => asset.name === `bun-${platform}-${arch}.zip`),
};
};
-16
View File
@@ -1,16 +0,0 @@
import fetch from 'node-fetch';
export default async (version, token) => {
let url;
if (version === 'latest')
url = 'https://api.github.com/repos/oven-sh/bun/releases/latest';
else
url = `https://api.github.com/repos/oven-sh/bun/releases/tags/bun-v${version}`;
const release = await (await fetch(url, {
headers: {
'Content-Type': 'application/json',
'User-Agent': 'setup-bun-github-action',
'Authorization': token
}
})).json();
return release;
};
Generated Vendored
-3
View File
@@ -1,3 +0,0 @@
export default () => {
return process.env[process.platform == 'win32' ? 'USERPROFILE' : 'HOME'];
};
Generated Vendored
-22
View File
@@ -1,22 +0,0 @@
import { cacheDir, downloadTool, extractZip, find } from '@actions/tool-cache';
import { addPath, info } from '@actions/core';
import getAsset from './getAsset.js';
import getHomeDir from './getHomeDir.js';
import { join } from 'path';
export default async (release) => {
const cache = find('bun', release.tag_name);
if (cache) {
info(`Using cached Bun installation from ${cache}.`);
addPath(cache);
return;
}
const asset = getAsset(release.assets);
info(`Downloading Bun from ${asset.asset.browser_download_url}.`);
const zipPath = await downloadTool(asset.asset.browser_download_url);
const extracted = await extractZip(zipPath, join(getHomeDir(), '.bun', 'bin'));
const newCache = await cacheDir(extracted, 'bun', release.tag_name);
info(`Cached Bun to ${newCache}.`);
addPath(newCache);
const bunPath = join(getHomeDir(), '.bun', 'bin', asset.name.replace('.zip', ''));
addPath(bunPath);
};
Generated Vendored
-1
View File
@@ -1 +0,0 @@
../semver/bin/semver.js
Generated Vendored
-1
View File
@@ -1 +0,0 @@
../typescript/bin/tsc
Generated Vendored
-1
View File
@@ -1 +0,0 @@
../typescript/bin/tsserver
Generated Vendored
-1
View File
@@ -1 +0,0 @@
../uuid/bin/uuid
-9
View File
@@ -1,9 +0,0 @@
The MIT License (MIT)
Copyright 2019 GitHub
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
-335
View File
@@ -1,335 +0,0 @@
# `@actions/core`
> Core functions for setting results, logging, registering secrets and exporting variables across actions
## Usage
### Import the package
```js
// javascript
const core = require('@actions/core');
// typescript
import * as core from '@actions/core';
```
#### Inputs/Outputs
Action inputs can be read with `getInput` which returns a `string` or `getBooleanInput` which parses a boolean based on the [yaml 1.2 specification](https://yaml.org/spec/1.2/spec.html#id2804923). If `required` set to be false, the input should have a default value in `action.yml`.
Outputs can be set with `setOutput` which makes them available to be mapped into inputs of other actions to ensure they are decoupled.
```js
const myInput = core.getInput('inputName', { required: true });
const myBooleanInput = core.getBooleanInput('booleanInputName', { required: true });
const myMultilineInput = core.getMultilineInput('multilineInputName', { required: true });
core.setOutput('outputKey', 'outputVal');
```
#### Exporting variables
Since each step runs in a separate process, you can use `exportVariable` to add it to this step and future steps environment blocks.
```js
core.exportVariable('envVar', 'Val');
```
#### Setting a secret
Setting a secret registers the secret with the runner to ensure it is masked in logs.
```js
core.setSecret('myPassword');
```
#### PATH Manipulation
To make a tool's path available in the path for the remainder of the job (without altering the machine or containers state), use `addPath`. The runner will prepend the path given to the jobs PATH.
```js
core.addPath('/path/to/mytool');
```
#### Exit codes
You should use this library to set the failing exit code for your action. If status is not set and the script runs to completion, that will lead to a success.
```js
const core = require('@actions/core');
try {
// Do stuff
}
catch (err) {
// setFailed logs the message and sets a failing exit code
core.setFailed(`Action failed with error ${err}`);
}
```
Note that `setNeutral` is not yet implemented in actions V2 but equivalent functionality is being planned.
#### Logging
Finally, this library provides some utilities for logging. Note that debug logging is hidden from the logs by default. This behavior can be toggled by enabling the [Step Debug Logs](../../docs/action-debugging.md#step-debug-logs).
```js
const core = require('@actions/core');
const myInput = core.getInput('input');
try {
core.debug('Inside try block');
if (!myInput) {
core.warning('myInput was not set');
}
if (core.isDebug()) {
// curl -v https://github.com
} else {
// curl https://github.com
}
// Do stuff
core.info('Output to the actions build log')
core.notice('This is a message that will also emit an annotation')
}
catch (err) {
core.error(`Error ${err}, action may still succeed though`);
}
```
This library can also wrap chunks of output in foldable groups.
```js
const core = require('@actions/core')
// Manually wrap output
core.startGroup('Do some function')
doSomeFunction()
core.endGroup()
// Wrap an asynchronous function call
const result = await core.group('Do something async', async () => {
const response = await doSomeHTTPRequest()
return response
})
```
#### Annotations
This library has 3 methods that will produce [annotations](https://docs.github.com/en/rest/reference/checks#create-a-check-run).
```js
core.error('This is a bad error. This will also fail the build.')
core.warning('Something went wrong, but it\'s not bad enough to fail the build.')
core.notice('Something happened that you might want to know about.')
```
These will surface to the UI in the Actions page and on Pull Requests. They look something like this:
![Annotations Image](../../docs/assets/annotations.png)
These annotations can also be attached to particular lines and columns of your source files to show exactly where a problem is occuring.
These options are:
```typescript
export interface AnnotationProperties {
/**
* A title for the annotation.
*/
title?: string
/**
* The name of the file for which the annotation should be created.
*/
file?: string
/**
* The start line for the annotation.
*/
startLine?: number
/**
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
*/
endLine?: number
/**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
*/
startColumn?: number
/**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
* Defaults to `startColumn` when `startColumn` is provided.
*/
endColumn?: number
}
```
#### Styling output
Colored output is supported in the Action logs via standard [ANSI escape codes](https://en.wikipedia.org/wiki/ANSI_escape_code). 3/4 bit, 8 bit and 24 bit colors are all supported.
Foreground colors:
```js
// 3/4 bit
core.info('\u001b[35mThis foreground will be magenta')
// 8 bit
core.info('\u001b[38;5;6mThis foreground will be cyan')
// 24 bit
core.info('\u001b[38;2;255;0;0mThis foreground will be bright red')
```
Background colors:
```js
// 3/4 bit
core.info('\u001b[43mThis background will be yellow');
// 8 bit
core.info('\u001b[48;5;6mThis background will be cyan')
// 24 bit
core.info('\u001b[48;2;255;0;0mThis background will be bright red')
```
Special styles:
```js
core.info('\u001b[1mBold text')
core.info('\u001b[3mItalic text')
core.info('\u001b[4mUnderlined text')
```
ANSI escape codes can be combined with one another:
```js
core.info('\u001b[31;46mRed foreground with a cyan background and \u001b[1mbold text at the end');
```
> Note: Escape codes reset at the start of each line
```js
core.info('\u001b[35mThis foreground will be magenta')
core.info('This foreground will reset to the default')
```
Manually typing escape codes can be a little difficult, but you can use third party modules such as [ansi-styles](https://github.com/chalk/ansi-styles).
```js
const style = require('ansi-styles');
core.info(style.color.ansi16m.hex('#abcdef') + 'Hello world!')
```
#### Action state
You can use this library to save state and get state for sharing information between a given wrapper action:
**action.yml**:
```yaml
name: 'Wrapper action sample'
inputs:
name:
default: 'GitHub'
runs:
using: 'node12'
main: 'main.js'
post: 'cleanup.js'
```
In action's `main.js`:
```js
const core = require('@actions/core');
core.saveState("pidToKill", 12345);
```
In action's `cleanup.js`:
```js
const core = require('@actions/core');
var pid = core.getState("pidToKill");
process.kill(pid);
```
#### OIDC Token
You can use these methods to interact with the GitHub OIDC provider and get a JWT ID token which would help to get access token from third party cloud providers.
**Method Name**: getIDToken()
**Inputs**
audience : optional
**Outputs**
A [JWT](https://jwt.io/) ID Token
In action's `main.ts`:
```js
const core = require('@actions/core');
async function getIDTokenAction(): Promise<void> {
const audience = core.getInput('audience', {required: false})
const id_token1 = await core.getIDToken() // ID Token with default audience
const id_token2 = await core.getIDToken(audience) // ID token with custom audience
// this id_token can be used to get access token from third party cloud providers
}
getIDTokenAction()
```
In action's `actions.yml`:
```yaml
name: 'GetIDToken'
description: 'Get ID token from Github OIDC provider'
inputs:
audience:
description: 'Audience for which the ID token is intended for'
required: false
outputs:
id_token1:
description: 'ID token obtained from OIDC provider'
id_token2:
description: 'ID token obtained from OIDC provider'
runs:
using: 'node12'
main: 'dist/index.js'
```
#### Filesystem path helpers
You can use these methods to manipulate file paths across operating systems.
The `toPosixPath` function converts input paths to Posix-style (Linux) paths.
The `toWin32Path` function converts input paths to Windows-style paths. These
functions work independently of the underlying runner operating system.
```js
toPosixPath('\\foo\\bar') // => /foo/bar
toWin32Path('/foo/bar') // => \foo\bar
```
The `toPlatformPath` function converts input paths to the expected value on the runner's operating system.
```js
// On a Windows runner.
toPlatformPath('/foo/bar') // => \foo\bar
// On a Linux runner.
toPlatformPath('\\foo\\bar') // => /foo/bar
```
-15
View File
@@ -1,15 +0,0 @@
export interface CommandProperties {
[key: string]: any;
}
/**
* Commands
*
* Command Format:
* ::name key=value,key=value::message
*
* Examples:
* ::warning::This is the message
* ::set-env name=MY_VAR::some value
*/
export declare function issueCommand(command: string, properties: CommandProperties, message: any): void;
export declare function issue(name: string, message?: string): void;
-92
View File
@@ -1,92 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.issue = exports.issueCommand = void 0;
const os = __importStar(require("os"));
const utils_1 = require("./utils");
/**
* Commands
*
* Command Format:
* ::name key=value,key=value::message
*
* Examples:
* ::warning::This is the message
* ::set-env name=MY_VAR::some value
*/
function issueCommand(command, properties, message) {
const cmd = new Command(command, properties, message);
process.stdout.write(cmd.toString() + os.EOL);
}
exports.issueCommand = issueCommand;
function issue(name, message = '') {
issueCommand(name, {}, message);
}
exports.issue = issue;
const CMD_STRING = '::';
class Command {
constructor(command, properties, message) {
if (!command) {
command = 'missing.command';
}
this.command = command;
this.properties = properties;
this.message = message;
}
toString() {
let cmdStr = CMD_STRING + this.command;
if (this.properties && Object.keys(this.properties).length > 0) {
cmdStr += ' ';
let first = true;
for (const key in this.properties) {
if (this.properties.hasOwnProperty(key)) {
const val = this.properties[key];
if (val) {
if (first) {
first = false;
}
else {
cmdStr += ',';
}
cmdStr += `${key}=${escapeProperty(val)}`;
}
}
}
}
cmdStr += `${CMD_STRING}${escapeData(this.message)}`;
return cmdStr;
}
}
function escapeData(s) {
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A');
}
function escapeProperty(s) {
return utils_1.toCommandValue(s)
.replace(/%/g, '%25')
.replace(/\r/g, '%0D')
.replace(/\n/g, '%0A')
.replace(/:/g, '%3A')
.replace(/,/g, '%2C');
}
//# sourceMappingURL=command.js.map
File diff suppressed because one or more lines are too long
-198
View File
@@ -1,198 +0,0 @@
/**
* Interface for getInput options
*/
export interface InputOptions {
/** Optional. Whether the input is required. If required and not present, will throw. Defaults to false */
required?: boolean;
/** Optional. Whether leading/trailing whitespace will be trimmed for the input. Defaults to true */
trimWhitespace?: boolean;
}
/**
* The code to exit an action
*/
export declare enum ExitCode {
/**
* A code indicating that the action was successful
*/
Success = 0,
/**
* A code indicating that the action was a failure
*/
Failure = 1
}
/**
* Optional properties that can be sent with annotatation commands (notice, error, and warning)
* See: https://docs.github.com/en/rest/reference/checks#create-a-check-run for more information about annotations.
*/
export interface AnnotationProperties {
/**
* A title for the annotation.
*/
title?: string;
/**
* The path of the file for which the annotation should be created.
*/
file?: string;
/**
* The start line for the annotation.
*/
startLine?: number;
/**
* The end line for the annotation. Defaults to `startLine` when `startLine` is provided.
*/
endLine?: number;
/**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
*/
startColumn?: number;
/**
* The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values.
* Defaults to `startColumn` when `startColumn` is provided.
*/
endColumn?: number;
}
/**
* Sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/
export declare function exportVariable(name: string, val: any): void;
/**
* Registers a secret which will get masked from logs
* @param secret value of the secret
*/
export declare function setSecret(secret: string): void;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath
*/
export declare function addPath(inputPath: string): void;
/**
* Gets the value of an input.
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
* Returns an empty string if the value is not defined.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string
*/
export declare function getInput(name: string, options?: InputOptions): string;
/**
* Gets the values of an multiline input. Each value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string[]
*
*/
export declare function getMultilineInput(name: string, options?: InputOptions): string[];
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
* The return value is also in boolean type.
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns boolean
*/
export declare function getBooleanInput(name: string, options?: InputOptions): boolean;
/**
* Sets the value of an output.
*
* @param name name of the output to set
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
export declare function setOutput(name: string, value: any): void;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
export declare function setCommandEcho(enabled: boolean): void;
/**
* Sets the action status to failed.
* When the action exits it will be with an exit code of 1
* @param message add error issue message
*/
export declare function setFailed(message: string | Error): void;
/**
* Gets whether Actions Step Debug is on or not
*/
export declare function isDebug(): boolean;
/**
* Writes debug message to user log
* @param message debug message
*/
export declare function debug(message: string): void;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
export declare function error(message: string | Error, properties?: AnnotationProperties): void;
/**
* Adds a warning issue
* @param message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
export declare function warning(message: string | Error, properties?: AnnotationProperties): void;
/**
* Adds a notice issue
* @param message notice issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
export declare function notice(message: string | Error, properties?: AnnotationProperties): void;
/**
* Writes info to log with console.log.
* @param message info message
*/
export declare function info(message: string): void;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
export declare function startGroup(name: string): void;
/**
* End an output group.
*/
export declare function endGroup(): void;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
export declare function group<T>(name: string, fn: () => Promise<T>): Promise<T>;
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
export declare function saveState(name: string, value: any): void;
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
export declare function getState(name: string): string;
export declare function getIDToken(aud?: string): Promise<string>;
/**
* Summary exports
*/
export { summary } from './summary';
/**
* @deprecated use core.summary
*/
export { markdownSummary } from './summary';
/**
* Path exports
*/
export { toPosixPath, toWin32Path, toPlatformPath } from './path-utils';
-329
View File
@@ -1,329 +0,0 @@
"use strict";
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.getIDToken = exports.getState = exports.saveState = exports.group = exports.endGroup = exports.startGroup = exports.info = exports.notice = exports.warning = exports.error = exports.debug = exports.isDebug = exports.setFailed = exports.setCommandEcho = exports.setOutput = exports.getBooleanInput = exports.getMultilineInput = exports.getInput = exports.addPath = exports.setSecret = exports.exportVariable = exports.ExitCode = void 0;
const command_1 = require("./command");
const file_command_1 = require("./file-command");
const utils_1 = require("./utils");
const os = __importStar(require("os"));
const path = __importStar(require("path"));
const oidc_utils_1 = require("./oidc-utils");
/**
* The code to exit an action
*/
var ExitCode;
(function (ExitCode) {
/**
* A code indicating that the action was successful
*/
ExitCode[ExitCode["Success"] = 0] = "Success";
/**
* A code indicating that the action was a failure
*/
ExitCode[ExitCode["Failure"] = 1] = "Failure";
})(ExitCode = exports.ExitCode || (exports.ExitCode = {}));
//-----------------------------------------------------------------------
// Variables
//-----------------------------------------------------------------------
/**
* Sets env variable for this action and future actions in the job
* @param name the name of the variable to set
* @param val the value of the variable. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function exportVariable(name, val) {
const convertedVal = utils_1.toCommandValue(val);
process.env[name] = convertedVal;
const filePath = process.env['GITHUB_ENV'] || '';
if (filePath) {
const delimiter = '_GitHubActionsFileCommandDelimeter_';
const commandValue = `${name}<<${delimiter}${os.EOL}${convertedVal}${os.EOL}${delimiter}`;
file_command_1.issueCommand('ENV', commandValue);
}
else {
command_1.issueCommand('set-env', { name }, convertedVal);
}
}
exports.exportVariable = exportVariable;
/**
* Registers a secret which will get masked from logs
* @param secret value of the secret
*/
function setSecret(secret) {
command_1.issueCommand('add-mask', {}, secret);
}
exports.setSecret = setSecret;
/**
* Prepends inputPath to the PATH (for this action and future actions)
* @param inputPath
*/
function addPath(inputPath) {
const filePath = process.env['GITHUB_PATH'] || '';
if (filePath) {
file_command_1.issueCommand('PATH', inputPath);
}
else {
command_1.issueCommand('add-path', {}, inputPath);
}
process.env['PATH'] = `${inputPath}${path.delimiter}${process.env['PATH']}`;
}
exports.addPath = addPath;
/**
* Gets the value of an input.
* Unless trimWhitespace is set to false in InputOptions, the value is also trimmed.
* Returns an empty string if the value is not defined.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string
*/
function getInput(name, options) {
const val = process.env[`INPUT_${name.replace(/ /g, '_').toUpperCase()}`] || '';
if (options && options.required && !val) {
throw new Error(`Input required and not supplied: ${name}`);
}
if (options && options.trimWhitespace === false) {
return val;
}
return val.trim();
}
exports.getInput = getInput;
/**
* Gets the values of an multiline input. Each value is also trimmed.
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns string[]
*
*/
function getMultilineInput(name, options) {
const inputs = getInput(name, options)
.split('\n')
.filter(x => x !== '');
return inputs;
}
exports.getMultilineInput = getMultilineInput;
/**
* Gets the input value of the boolean type in the YAML 1.2 "core schema" specification.
* Support boolean input list: `true | True | TRUE | false | False | FALSE` .
* The return value is also in boolean type.
* ref: https://yaml.org/spec/1.2/spec.html#id2804923
*
* @param name name of the input to get
* @param options optional. See InputOptions.
* @returns boolean
*/
function getBooleanInput(name, options) {
const trueValue = ['true', 'True', 'TRUE'];
const falseValue = ['false', 'False', 'FALSE'];
const val = getInput(name, options);
if (trueValue.includes(val))
return true;
if (falseValue.includes(val))
return false;
throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${name}\n` +
`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``);
}
exports.getBooleanInput = getBooleanInput;
/**
* Sets the value of an output.
*
* @param name name of the output to set
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function setOutput(name, value) {
process.stdout.write(os.EOL);
command_1.issueCommand('set-output', { name }, value);
}
exports.setOutput = setOutput;
/**
* Enables or disables the echoing of commands into stdout for the rest of the step.
* Echoing is disabled by default if ACTIONS_STEP_DEBUG is not set.
*
*/
function setCommandEcho(enabled) {
command_1.issue('echo', enabled ? 'on' : 'off');
}
exports.setCommandEcho = setCommandEcho;
//-----------------------------------------------------------------------
// Results
//-----------------------------------------------------------------------
/**
* Sets the action status to failed.
* When the action exits it will be with an exit code of 1
* @param message add error issue message
*/
function setFailed(message) {
process.exitCode = ExitCode.Failure;
error(message);
}
exports.setFailed = setFailed;
//-----------------------------------------------------------------------
// Logging Commands
//-----------------------------------------------------------------------
/**
* Gets whether Actions Step Debug is on or not
*/
function isDebug() {
return process.env['RUNNER_DEBUG'] === '1';
}
exports.isDebug = isDebug;
/**
* Writes debug message to user log
* @param message debug message
*/
function debug(message) {
command_1.issueCommand('debug', {}, message);
}
exports.debug = debug;
/**
* Adds an error issue
* @param message error issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function error(message, properties = {}) {
command_1.issueCommand('error', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.error = error;
/**
* Adds a warning issue
* @param message warning issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function warning(message, properties = {}) {
command_1.issueCommand('warning', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.warning = warning;
/**
* Adds a notice issue
* @param message notice issue message. Errors will be converted to string via toString()
* @param properties optional properties to add to the annotation.
*/
function notice(message, properties = {}) {
command_1.issueCommand('notice', utils_1.toCommandProperties(properties), message instanceof Error ? message.toString() : message);
}
exports.notice = notice;
/**
* Writes info to log with console.log.
* @param message info message
*/
function info(message) {
process.stdout.write(message + os.EOL);
}
exports.info = info;
/**
* Begin an output group.
*
* Output until the next `groupEnd` will be foldable in this group
*
* @param name The name of the output group
*/
function startGroup(name) {
command_1.issue('group', name);
}
exports.startGroup = startGroup;
/**
* End an output group.
*/
function endGroup() {
command_1.issue('endgroup');
}
exports.endGroup = endGroup;
/**
* Wrap an asynchronous function call in a group.
*
* Returns the same type as the function itself.
*
* @param name The name of the group
* @param fn The function to wrap in the group
*/
function group(name, fn) {
return __awaiter(this, void 0, void 0, function* () {
startGroup(name);
let result;
try {
result = yield fn();
}
finally {
endGroup();
}
return result;
});
}
exports.group = group;
//-----------------------------------------------------------------------
// Wrapper action state
//-----------------------------------------------------------------------
/**
* Saves state for current action, the state can only be retrieved by this action's post job execution.
*
* @param name name of the state to store
* @param value value to store. Non-string values will be converted to a string via JSON.stringify
*/
// eslint-disable-next-line @typescript-eslint/no-explicit-any
function saveState(name, value) {
command_1.issueCommand('save-state', { name }, value);
}
exports.saveState = saveState;
/**
* Gets the value of an state set by this action's main execution.
*
* @param name name of the state to get
* @returns string
*/
function getState(name) {
return process.env[`STATE_${name}`] || '';
}
exports.getState = getState;
function getIDToken(aud) {
return __awaiter(this, void 0, void 0, function* () {
return yield oidc_utils_1.OidcClient.getIDToken(aud);
});
}
exports.getIDToken = getIDToken;
/**
* Summary exports
*/
var summary_1 = require("./summary");
Object.defineProperty(exports, "summary", { enumerable: true, get: function () { return summary_1.summary; } });
/**
* @deprecated use core.summary
*/
var summary_2 = require("./summary");
Object.defineProperty(exports, "markdownSummary", { enumerable: true, get: function () { return summary_2.markdownSummary; } });
/**
* Path exports
*/
var path_utils_1 = require("./path-utils");
Object.defineProperty(exports, "toPosixPath", { enumerable: true, get: function () { return path_utils_1.toPosixPath; } });
Object.defineProperty(exports, "toWin32Path", { enumerable: true, get: function () { return path_utils_1.toWin32Path; } });
Object.defineProperty(exports, "toPlatformPath", { enumerable: true, get: function () { return path_utils_1.toPlatformPath; } });
//# sourceMappingURL=core.js.map
-1
View File
File diff suppressed because one or more lines are too long
-1
View File
@@ -1 +0,0 @@
export declare function issueCommand(command: string, message: any): void;
-42
View File
@@ -1,42 +0,0 @@
"use strict";
// For internal use, subject to change.
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } });
}) : (function(o, m, k, k2) {
if (k2 === undefined) k2 = k;
o[k2] = m[k];
}));
var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
Object.defineProperty(o, "default", { enumerable: true, value: v });
}) : function(o, v) {
o["default"] = v;
});
var __importStar = (this && this.__importStar) || function (mod) {
if (mod && mod.__esModule) return mod;
var result = {};
if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
__setModuleDefault(result, mod);
return result;
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.issueCommand = void 0;
// We use any as a valid input type
/* eslint-disable @typescript-eslint/no-explicit-any */
const fs = __importStar(require("fs"));
const os = __importStar(require("os"));
const utils_1 = require("./utils");
function issueCommand(command, message) {
const filePath = process.env[`GITHUB_${command}`];
if (!filePath) {
throw new Error(`Unable to find environment variable for file command ${command}`);
}
if (!fs.existsSync(filePath)) {
throw new Error(`Missing file at path: ${filePath}`);
}
fs.appendFileSync(filePath, `${utils_1.toCommandValue(message)}${os.EOL}`, {
encoding: 'utf8'
});
}
exports.issueCommand = issueCommand;
//# sourceMappingURL=file-command.js.map

Some files were not shown because too many files have changed in this diff Show More