diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 36adeae..77d89fc 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -17,39 +17,55 @@ jobs: - name: Checkout code uses: actions/checkout@0ad4b8fadaa221de15dcec353f45205ec38ea70b # v4.1.4 - - name: Run dev - id: tag_dev + - name: Run dev with error cases (should fail) run: | + echo "Testing with no GITHUB_REF set" GITHUB_REF="" node main.js # shellcheck disable=SC2181 if [ $? -ne 1 ]; then echo "Expected failure on no GITHUB_REF set"; fi + - name: Run dev with error cases (should fail) + if: always() + run: | + echo "Testing with invalid GITHUB_REF" GITHUB_REF=origin/refs/tag/v1 node main.js # shellcheck disable=SC2181 if [ $? -ne 1 ]; then echo "Expected failure on invalid ref"; fi + - name: Run dev with different error cases (should fail) + if: always() + run: | + echo "Testing with valid GITHUB_REF" GITHUB_REF=refs/tag/v1 node main.js # shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to tag"; fi + - name: Run dev + id: tag_dev + run: | + echo "Testing with valid GITHUB_REF" GITHUB_REF=refs/heads/main node main.js # shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref to branch"; fi + echo "Testing with valid GITHUB_REF" GITHUB_REF=refs/tags/v1.0.0 node main.js # shellcheck disable=SC2181 if [ $? -ne 0 ]; then echo "Not expected a failure on valid ref with minor version"; fi - name: Test dev + if: always() run: | test "v1.0.0" = "${{steps.tag_dev.outputs.tag}}" - name: Run dev with strip v + if: always() id: tag_dev_strip_v run: | - GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V=true node main.js + GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="true" node main.js - name: Test dev with strip v + if: always() run: | test "1.0.0" = "${{steps.tag_dev_strip_v.outputs.tag}}" @@ -62,3 +78,29 @@ jobs: if: startsWith(github.ref, 'refs/tags') == true run: | test -n "${{steps.tag_prod.outputs.tag}}" + + + - name: Run dev with no strip_v and a default + if: always() + id: tag_dev_no_strip_v_default + run: | + GITHUB_REF=refs/tags/v1.0.0 INPUT_STRIP_V="false" INPUT_DEFAULT="v0.0.0" node main.js + + - name: Test dev with no strip_v and default value + if: always() + run: | + test "v1.0.0" = "${{steps.tag_dev_no_strip_v_default.outputs.tag}}" + + + - name: Run dev with no tag, no strip_v and a default and not a tag + if: always() + id: no_tag_dev_no_strip_v_default + run: | + GITHUB_REF=random_branch INPUT_STRIP_V="false" INPUT_DEFAULT="v0.99.0" node main.js + + - name: Test dev with no tag, no strip_v and default value + if: always() + run: | + test "v0.99.0" = "${{steps.no_tag_dev_no_strip_v_default.outputs.tag}}" + + diff --git a/README.md b/README.md index c144be4..5ce7bf3 100644 --- a/README.md +++ b/README.md @@ -21,7 +21,7 @@ on: ```yaml - name: Get tag id: tag - uses: devops-actions/action-get-tag@v1.0.1 + uses: devops-actions/action-get-tag@v1.0.2 with: strip_v: true # Optional: Remove 'v' character from version default: v0.0.0 # Optional: Default version when tag not found diff --git a/action.yml b/action.yml index 8c23ad9..206c2f2 100644 --- a/action.yml +++ b/action.yml @@ -6,7 +6,7 @@ branding: inputs: strip_v: required: false - default: false + default: "false" description: Whether to strip "v" from the tag or not (optional) default: required: false diff --git a/main.js b/main.js index 5ff9550..57ddad3 100644 --- a/main.js +++ b/main.js @@ -18,7 +18,7 @@ async function main() { throw `Not a tag ref (${ref}) or default version not set` if(!tag) - throw `Not tag version found` + throw `No tag version found` if(strip_v === "true" && tag.startsWith("v")) tag = tag.replace(/^v/, "") diff --git a/node_modules/.package-lock.json b/node_modules/.package-lock.json index 16363fe..15cc3fb 100644 --- a/node_modules/.package-lock.json +++ b/node_modules/.package-lock.json @@ -4,9 +4,9 @@ "requires": true, "packages": { "node_modules/@actions/core": { - "version": "1.10.0", - "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.0.tgz", - "integrity": "sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==", + "version": "1.10.1", + "resolved": "https://registry.npmjs.org/@actions/core/-/core-1.10.1.tgz", + "integrity": "sha512-3lBR9EDAY+iYIpTnTIXmWcNbX3T2kCkAEQGIQx4NVQ0575nk2k3GRZDTPQG+vVtS2izSLmINlxXf0uLtnrTP+g==", "dependencies": { "@actions/http-client": "^2.0.1", "uuid": "^8.3.2" diff --git a/node_modules/@actions/core/README.md b/node_modules/@actions/core/README.md index 3c20c8e..8a47143 100644 --- a/node_modules/@actions/core/README.md +++ b/node_modules/@actions/core/README.md @@ -121,7 +121,7 @@ const result = await core.group('Do something async', async () => { 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.error('This is a bad error, action may still succeed though.') core.warning('Something went wrong, but it\'s not bad enough to fail the build.') @@ -163,7 +163,7 @@ export interface AnnotationProperties { startColumn?: number /** - * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. + * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. * Defaults to `startColumn` when `startColumn` is provided. */ endColumn?: number diff --git a/node_modules/@actions/core/lib/core.d.ts b/node_modules/@actions/core/lib/core.d.ts index 1defb57..ceecdd3 100644 --- a/node_modules/@actions/core/lib/core.d.ts +++ b/node_modules/@actions/core/lib/core.d.ts @@ -21,7 +21,7 @@ export declare enum ExitCode { Failure = 1 } /** - * Optional properties that can be sent with annotatation commands (notice, error, and warning) + * Optional properties that can be sent with annotation 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 { @@ -46,7 +46,7 @@ export interface AnnotationProperties { */ startColumn?: number; /** - * The start column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. + * The end column for the annotation. Cannot be sent when `startLine` and `endLine` are different values. * Defaults to `startColumn` when `startColumn` is provided. */ endColumn?: number; diff --git a/node_modules/@actions/core/lib/oidc-utils.js b/node_modules/@actions/core/lib/oidc-utils.js index f701277..092e93d 100644 --- a/node_modules/@actions/core/lib/oidc-utils.js +++ b/node_modules/@actions/core/lib/oidc-utils.js @@ -44,7 +44,7 @@ class OidcClient { .catch(error => { throw new Error(`Failed to get ID Token. \n Error Code : ${error.statusCode}\n - Error Message: ${error.result.message}`); + Error Message: ${error.message}`); }); const id_token = (_a = res.result) === null || _a === void 0 ? void 0 : _a.value; if (!id_token) { diff --git a/node_modules/@actions/core/lib/oidc-utils.js.map b/node_modules/@actions/core/lib/oidc-utils.js.map index 284fa1d..22506b8 100644 --- a/node_modules/@actions/core/lib/oidc-utils.js.map +++ b/node_modules/@actions/core/lib/oidc-utils.js.map @@ -1 +1 @@ -{"version":3,"file":"oidc-utils.js","sourceRoot":"","sources":["../src/oidc-utils.ts"],"names":[],"mappings":";;;;;;;;;;;;AAGA,sDAA+C;AAC/C,wDAAqE;AACrE,iCAAuC;AAKvC,MAAa,UAAU;IACb,MAAM,CAAC,gBAAgB,CAC7B,UAAU,GAAG,IAAI,EACjB,QAAQ,GAAG,EAAE;QAEb,MAAM,cAAc,GAAmB;YACrC,YAAY,EAAE,UAAU;YACxB,UAAU,EAAE,QAAQ;SACrB,CAAA;QAED,OAAO,IAAI,wBAAU,CACnB,qBAAqB,EACrB,CAAC,IAAI,8BAAuB,CAAC,UAAU,CAAC,eAAe,EAAE,CAAC,CAAC,EAC3D,cAAc,CACf,CAAA;IACH,CAAC;IAEO,MAAM,CAAC,eAAe;QAC5B,MAAM,KAAK,GAAG,OAAO,CAAC,GAAG,CAAC,gCAAgC,CAAC,CAAA;QAC3D,IAAI,CAAC,KAAK,EAAE;YACV,MAAM,IAAI,KAAK,CACb,2DAA2D,CAC5D,CAAA;SACF;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IAEO,MAAM,CAAC,aAAa;QAC1B,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,CAAC,8BAA8B,CAAC,CAAA;QAC9D,IAAI,CAAC,UAAU,EAAE;YACf,MAAM,IAAI,K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,KAAK,CAAA;YAClC,IAAI,CAAC,QAAQ,EAAE;gBACb,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;aACjE;YACD,OAAO,QAAQ,CAAA;;KAChB;IAED,MAAM,CAAO,UAAU,CAAC,QAAiB;;YACvC,IAAI;gBACF,gDAAgD;gBAChD,IAAI,YAAY,GAAW,UAAU,CAAC,aAAa,EAAE,CAAA;gBACrD,IAAI,QAAQ,EAAE;oBACZ,MAAM,eAAe,GAAG,kBAAkB,CAAC,QAAQ,CAAC,CAAA;oBACpD,YAAY,GAAG,GAAG,YAAY,aAAa,eAAe,EAAE,CAAA;iBAC7D;gBAED,YAAK,CAAC,mBAAmB,YAAY,EAAE,CAAC,CAAA;gBAExC,MAAM,QAAQ,GAAG,MAAM,UAAU,CAAC,OAAO,CAAC,YAAY,CAAC,CAAA;gBACvD,gBAAS,CAAC,QAAQ,CAAC,CAAA;gBACnB,OAAO,QAAQ,CAAA;aAChB;YAAC,OAAO,KAAK,EAAE;gBACd,MAAM,IAAI,KAAK,CAAC,kBAAkB,KAAK,CAAC,OAAO,EAAE,CAAC,CAAA;aACnD;QACH,CAAC;KAAA;CACF;AAzED,gCAyEC"} \ No newline at end of file diff --git a/node_modules/@actions/core/package.json b/node_modules/@actions/core/package.json index 1f3824d..1558268 100644 --- a/node_modules/@actions/core/package.json +++ b/node_modules/@actions/core/package.json @@ -1,6 +1,6 @@ { "name": "@actions/core", - "version": "1.10.0", + "version": "1.10.1", "description": "Actions core lib", "keywords": [ "github", @@ -30,7 +30,7 @@ "scripts": { "audit-moderate": "npm install && npm audit --json --audit-level=moderate > audit.json", "test": "echo \"Error: run tests from root\" && exit 1", - "tsc": "tsc" + "tsc": "tsc -p tsconfig.json" }, "bugs": { "url": "https://github.com/actions/toolkit/issues" @@ -43,4 +43,4 @@ "@types/node": "^12.0.2", "@types/uuid": "^8.3.4" } -} +} \ No newline at end of file