Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 6 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,11 +39,12 @@ Besides a status, meshStack can also show custom user messages consuming the ser

### inputs:
- `step_id`: (required) The ID of the step
- `status`: (required) The status of the step (SUCCEEDED or FAILED)
- `step_status`: (required) The status of the step (SUCCEEDED or FAILED)
- `user_message`: (optional) The user message for a failed step
- `system_message`: (optional) The system message for a failed step
- `is_final`: (optional) Indicates if this is the final status report (default: 'false')
- `summary`: (optional) The summary message for the final status report
- `outputs_json`: (optional) A JSON object with outputs of the step. All step outputs in a run will be merged by
- `run_status`: (optional) Indicates if this is the final status report (default: 'false')
meshStack to produce the run outputs. See the [API documentation](https://docs.meshcloud.io/api/index.html#_update_sources_and_steps) for more details on how to use this field.

## Example Usage

Expand Down Expand Up @@ -74,3 +75,5 @@ Besides a status, meshStack can also show custom user messages consuming the ser
user_message: ${{ steps.terraform-validate.outcome == 'success' && 'Successful plan Terraform configuration.' || 'Failed to plan Terraform configuration.' }}
system_message: ${{ steps.terraform-validate.outcome == 'success' && 'Successful plan Terraform configuration.' || 'Failed to plan Terraform configuration.' }}
```


14 changes: 7 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,22 +4,22 @@ inputs:
step_id:
description: 'The ID of the step'
required: false
status:
description: 'The status of the step (SUCCEEDED or FAILED)'
step_status:
description: 'The status of the step (IN_PROGRESS, SUCCEEDED or FAILED)'
required: false
user_message:
description: 'The user message for a failed step'
required: false
system_message:
description: 'The system message for a failed step'
required: false
final_status:
description: 'The final status is the end-state of the run, combining all step outcomes into one status result based on your logic.'
run_status:
description: 'The final status of the run. Sending this to a terminate status like SUCCEEDED or FAILED signals to meshStack that the run is complete. Send this only once.'
required: false
summary:
description: 'The summary message for the final status report'
outputs_json:
description: 'A json objects with outputs of the step. All outputs in a run will be merged by meshStack.'
required: false
default: '{}'
runs:
using: 'node20'
main: 'dist/index.js'

40 changes: 33 additions & 7 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28013,16 +28013,38 @@ const axios_1 = __importDefault(__nccwpck_require__(8757));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037));
function parseAndValidateOutputsJson(input) {
try {
const parsed = JSON.parse(input);
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
throw new Error('outputs_json must be a valid JSON object');
}
return parsed;
}
catch (error) {
const errorMessage = `Invalid outputs_json provided: ${error instanceof Error ? error.message : 'Unknown parsing error'}. Input was: ${input}`;
core.error(errorMessage);
throw new Error(errorMessage);
}
}
async function run() {
try {
let baseUrl;
let bbRunUuid;
const stepId = core.getInput('step_id');
const status = core.getInput('status');
const stepStatus = core.getInput('step_status');
const userMessage = core.getInput('user_message');
const systemMessage = core.getInput('system_message');
const summary = core.getInput('summary');
const finalStatus = core.getInput('final_status');
const runStatus = core.getInput('run_status');
const outputsJsonInput = core.getInput('outputs_json');
let outputsJson;
try {
outputsJson = parseAndValidateOutputsJson(outputsJsonInput);
}
catch (error) {
core.setFailed(error instanceof Error ? error.message : 'Unknown error occurred while parsing outputs_json');
return;
}
const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
core.debug(`Temporary directory: ${tempDir}`);
console.log(`Temporary directory: ${tempDir}`); // This will also print the path to the console
Expand Down Expand Up @@ -28053,15 +28075,15 @@ async function run() {
return;
}
const data = {
status: finalStatus ? finalStatus : "IN_PROGRESS",
summary: summary
status: runStatus ? runStatus : "IN_PROGRESS",
};
if (stepId) {
data.steps = [{
id: stepId,
status: status,
status: stepStatus,
userMessage: userMessage,
systemMessage: systemMessage
systemMessage: systemMessage,
outputs: outputsJson
}];
}
;
Expand All @@ -28079,6 +28101,10 @@ async function run() {
catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
if (error.response) {
core.error(`API response status: ${error.response.status}`);
core.error(`API response data: ${JSON.stringify(error.response.data)}`);
}
}
else {
core.setFailed('An unknown error occurred');
Expand Down
27 changes: 27 additions & 0 deletions flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

16 changes: 16 additions & 0 deletions flake.nix
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
{
description = "A flake that installs Node.js";

inputs.nixpkgs.url = "github:NixOS/nixpkgs/nixos-25.05";

outputs = { self, nixpkgs }:
let
system = "aarch64-darwin"; # Change to your system if needed
pkgs = import nixpkgs { inherit system; };
in {
packages.${system}.default = pkgs.nodejs;
devShells.${system}.default = pkgs.mkShell {
buildInputs = [ pkgs.nodejs ];
};
};
}
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "actions-send-status",
"version": "1.0.0",
"version": "2.0.0-beta.1",
"main": "index.js",
"scripts": {
"build": "ncc build src/index.ts -o dist",
Expand Down
41 changes: 34 additions & 7 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,17 +4,40 @@ import * as fs from 'fs';
import * as path from 'path';
import * as os from 'os';

function parseAndValidateOutputsJson(input: string): object {
try {
const parsed = JSON.parse(input);
if (typeof parsed !== 'object' || parsed === null || Array.isArray(parsed)) {
throw new Error('outputs_json must be a valid JSON object');
}

return parsed;
} catch (error) {
const errorMessage = `Invalid outputs_json provided: ${error instanceof Error ? error.message : 'Unknown parsing error'}. Input was: ${input}`;
core.error(errorMessage);
throw new Error(errorMessage);
}
}

async function run() {
try {
let baseUrl: string;
let bbRunUuid: string;

const stepId = core.getInput('step_id');
const status = core.getInput('status');
const stepStatus = core.getInput('step_status');
const userMessage = core.getInput('user_message');
const systemMessage = core.getInput('system_message');
const summary = core.getInput('summary');
const finalStatus = core.getInput('final_status');
const runStatus = core.getInput('run_status');
const outputsJsonInput = core.getInput('outputs_json')

let outputsJson: object;
try {
outputsJson = parseAndValidateOutputsJson(outputsJsonInput);
} catch (error) {
core.setFailed(error instanceof Error ? error.message : 'Unknown error occurred while parsing outputs_json');
return;
}

const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
core.debug(`Temporary directory: ${tempDir}`);
Expand Down Expand Up @@ -49,16 +72,16 @@ async function run() {
}

const data: any = {
status: finalStatus ? finalStatus : "IN_PROGRESS",
summary: summary
status: runStatus ? runStatus : "IN_PROGRESS",
};

if (stepId) {
data.steps = [{
id: stepId,
status: status,
status: stepStatus,
userMessage: userMessage,
systemMessage: systemMessage
systemMessage: systemMessage,
outputs: outputsJson
}]
};

Expand All @@ -81,6 +104,10 @@ async function run() {
} catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
if ((error as any).response) {
core.error(`API response status: ${(error as any).response.status}`);
core.error(`API response data: ${JSON.stringify((error as any).response.data)}`);
}
} else {
core.setFailed('An unknown error occurred');
}
Expand Down