Skip to content

Commit

Permalink
send message debuging
Browse files Browse the repository at this point in the history
  • Loading branch information
florianow committed Nov 8, 2024
1 parent 9519c49 commit 9e51f9a
Show file tree
Hide file tree
Showing 4 changed files with 57 additions and 14 deletions.
42 changes: 42 additions & 0 deletions .github/workflows/test.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: Test Action

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Copy meshstack_token.json to temp directory
run: |
mkdir -p $RUNNER_TEMP
cp test_data/meshstack_token.json $RUNNER_TEMP/meshstack_token.json
- name: Setup Meshstack Authentication
id: setup-meshstack-auth
uses: meshcloud/actions-register-source@main
with:
steps: |
[
{ "id": "terraform-validate", "displayName": "terraform validate" },
{ "id": "terraform-plan", "displayName": "terraform plan" },
{ "id": "terraform-apply", "displayName": "terraform apply" }
]
client_id: ${{ secrets.CLIENT_ID }}
key_secret: ${{ secrets.KEY_SECRET }}

- name: Run Action
id: run-action
uses: ./
with:
step_id: 'terrafrom-validate'
status: 'SUCCESS'
user_message: 'User message'
system_message: 'System message'
is_final: 'true'
summary: 'Summary message'

- name: Display temp directory
run: echo "Temporary directory is ${{ steps.run-action.outputs.temp_directory }}"

17 changes: 7 additions & 10 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037));
async function run() {
try {
// const baseUrl = core.getInput('base_url');
// const bbRunUuid = core.getInput('bb_run_uuid');
let baseUrl;
let bbRunUuid;
const stepId = core.getInput('step_id');
const status = core.getInput('status');
const userMessage = core.getInput('user_message');
Expand All @@ -54,8 +54,6 @@ async function run() {
// Set the temporary directory path as an output
core.setOutput('temp_directory', tempDir);
let token;
let baseUrl;
let bbRunUuid;
try {
const tokenFilePath = path.join(tempDir, 'meshstack_token.json');
core.debug(`Token file path: ${tokenFilePath}`);
Expand Down Expand Up @@ -83,17 +81,16 @@ async function run() {
status: isFinal ? status : "IN_PROGRESS",
steps: [{
id: stepId,
status: status
status: status,
userMessage: userMessage,
systemMessage: systemMessage
}]
};
if (status === 'FAILED') {
data.steps[0].userMessage = userMessage;
data.steps[0].systemMessage = systemMessage;
}
if (isFinal) {
data.summary = summary;
data.steps = [];
}
core.debug(`Constructed data object: ${JSON.stringify(data)}`);
console.log(`Constructed data object: ${JSON.stringify(data)}`);
const response = await axios_1.default.patch(`${baseUrl}/api/meshobjects/meshbuildingblockruns/${bbRunUuid}/status/source/github`, data, {
headers: {
'Content-Type': 'application/vnd.meshcloud.api.meshbuildingblockrun.v1.hal+json',
Expand Down
7 changes: 3 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,9 +48,6 @@ async function run() {
return;
}

core.debug(`Constructed data object: ${JSON.stringify(data)}`);
console.log(`Constructed data object: ${JSON.stringify(data)}`);

const data: any = {
status: isFinal ? status : "IN_PROGRESS",
steps: [{
Expand All @@ -63,9 +60,11 @@ async function run() {

if (isFinal) {
data.summary = summary;
data.steps = [];
}

core.debug(`Constructed data object: ${JSON.stringify(data)}`);
console.log(`Constructed data object: ${JSON.stringify(data)}`);

const response = await axios.patch(
`${baseUrl}/api/meshobjects/meshbuildingblockruns/${bbRunUuid}/status/source/github`,
data,
Expand Down
5 changes: 5 additions & 0 deletions test_data/event.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"inputs": {
"buildingBlockRun": "eyJtZXRhZGF0YSI6eyJ1dWlkIjoiZWM3YjgyMTMtNDk0YS00MDAyLTlhNGYtOGQzMjEwMThlN2Q4In0sIl9saW5rcyI6eyJtZXNoc3RhY2tCYXNlVXJsIjp7ImhyZWYiOiJodHRwczovL2ZlZGVyYXRpb24uZGV2Lm1lc2hjbG91ZC5pbyJ9fSwic3BlYyI6eyJidWlsZGluZ0Jsb2NrIjp7InNwZWMiOnsiaW5wdXRzIjpbeyJwcm9qZWN0TmFtZSI6ImV4YW1wbGVQcm9qZWN0IiwiZW5pcm9ubWVudCI6InByb2R1Y3Rpb24iLCJyZWdpb24iOiJ1cy13ZXN0LTEifV19fX19Cg=="
}
}

0 comments on commit 9e51f9a

Please sign in to comment.