Skip to content

Commit 9170625

Browse files
Merge pull request #1 from meshcloud/feature/meshstack-2025.53
feature/meshstack 2025.53
2 parents 13aff25 + 0b03378 commit 9170625

File tree

11 files changed

+1428
-5380
lines changed

11 files changed

+1428
-5380
lines changed

.github/workflows/ci.yml

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
name: CI Tests
2+
3+
on:
4+
push:
5+
branches: [ main, develop, 'feature/**' ]
6+
pull_request:
7+
branches: [ main, develop ]
8+
9+
jobs:
10+
build:
11+
runs-on: ubuntu-latest
12+
13+
strategy:
14+
matrix:
15+
node-version: [24.x]
16+
17+
steps:
18+
- name: Checkout code
19+
uses: actions/checkout@v4
20+
21+
- name: Setup Node.js ${{ matrix.node-version }}
22+
uses: actions/setup-node@v4
23+
with:
24+
node-version: ${{ matrix.node-version }}
25+
cache: 'npm'
26+
27+
- name: Install dependencies
28+
run: npm ci
29+
30+
- name: Run tests
31+
run: npm test
32+
33+
- name: Build action
34+
run: npm run build
35+
36+
- name: Check if dist/ is up to date
37+
run: |
38+
if [ -n "$(git status --porcelain dist/)" ]; then
39+
echo "dist/ directory is not up to date. Please run 'npm run build' and commit the changes."
40+
git status --porcelain dist/
41+
exit 1
42+
fi

.github/workflows/test.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ jobs:
77
- name: Checkout repository
88
uses: actions/checkout@v2
99

10-
- name: Setup Meshstack Authentication
10+
- name: Setup meshStack Authentication
1111
id: setup-meshstack-auth
1212
uses: ./
1313
with:

README.md

Lines changed: 89 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -1,58 +1,107 @@
1-
# Register Source GitHub Action
1+
# meshStack Register Source Action
22

3-
This GitHub Action registers sources to the meshStack Building Block pipeline workflow. It integrates with the meshStack API to update the status of a Building Block Run with the specified steps.
3+
This GitHub Action registers building block sources and steps with meshStack. It integrates with the meshStack API to set up the structure of a building block run with the specified steps. This allows platform teams
4+
to provide additional feedback about building block execution to application teams.
45

5-
### Overview
6+
## Overview
67

7-
The meshStack Building Block pipeline allows you to automate and manage complex workflows by defining a series of steps that need to be executed. Each Building Block Run represents an instance of such a workflow. This GitHub Action helps you register the source of the run and update its status with the specified steps.
8+
A meshStack building block run allows you to automate and manage complex workflows by defining a series of steps that need to be executed. This GitHub Action helps you register the source of the run and define its steps.
89

9-
In order to return updates for a run to meshStack, you first need to register one or multiple steps and their resources of your run execution. It is up to you how many or how you organize your steps. You can, however, also just send step results back and the registration takes place on the fly. But in order to have a consistent display and ordering of steps, it is highly advised to pre-register steps and sources.
10+
It is up to you how many or how you organize your steps. You can, however, also just send step results back and the registration takes place on the fly. But in order to have a consistent display and ordering of steps, it is highly advised to pre-register all steps that you plan to execute.
1011

11-
For more details on the meshBuildingBlockRun API, refer to the [meshcloud API documentation](https://docs.meshcloud.io/api/index.html#mesh_buildingblockrun).
12+
## Related Actions
1213

13-
For more information on integrating with the meshStack Building Block pipeline, refer to the [meshStack Building Block pipeline integration documentation](https://docs.meshcloud.io/docs/meshstack.building-pipeline-integration.html#building-block-run-and-steps).
14+
This action is part of a suite of GitHub Actions for meshStack building block automation:
1415

15-
### Building Block Inputs:
16+
- **[actions-meshstack-auth](https://github.com/meshcloud/actions-meshstack-auth)** - Authenticates to the meshStack API (prerequisite for this action)
17+
- **[actions-register-source](https://github.com/meshcloud/actions-register-source)** (this action) - Registers building block sources and steps with meshStack
18+
- **[actions-send-status](https://github.com/meshcloud/actions-send-status)** - Sends building block step status updates to meshStack
1619

17-
When MeshStack triggers your pipeline, it sends a GitHub Actions event containing the URL, building block ID, and all the inputs your building block needs. These inputs are written to `GITHUB_OUTPUT`. You can use these inputs in your pipeline with the syntax `${{ steps.setup-meshstack-auth.outputs.your_input_from_meshstack_bb }}`.
20+
## Documentation
1821

19-
For more information, refer to the [MeshStack documentation on building block inputs](https://docs.meshcloud.io/docs/administration.building-blocks.html#building-block-inputs).
22+
For more information about meshStack building blocks and GitHub Actions integration, refer to:
23+
- [meshStack GitHub Actions Integration](https://docs.meshcloud.io/integrations/github/github-actions/)
24+
- [meshStack API Documentation](https://docs.meshcloud.io/api/index.html#mesh_buildingblockrun)
2025

21-
### Inputs
26+
## Building Block Inputs
2227

23-
- `client_id` (required): The client ID for the API.
24-
- `key_secret` (required): The key secret for the API.
25-
- `steps` (required): The steps to register.
28+
When meshStack triggers your pipeline, it sends a GitHub Actions event containing the URL, building block ID, and all the inputs your building block needs. These inputs are written to `GITHUB_OUTPUT`. You can use these inputs in your pipeline with the syntax `${{ steps.setup-meshstack-auth.outputs.your_input_from_meshstack_bb }}`.
2629

27-
### Outputs
30+
For more information, refer to the [meshStack documentation on building block inputs](https://docs.meshcloud.io/docs/administration.building-blocks.html#building-block-inputs).
31+
32+
## Inputs
33+
34+
- `steps` (required): JSON array of steps to register. Each step should have an `id` and `displayName`.
35+
36+
## Outputs
2837

2938
- `token_file`: Path to the file containing the authentication token
39+
- Dynamic outputs based on building block inputs (e.g., custom parameters defined in your building block)
40+
41+
## Required GitHub Context Parameters
42+
43+
This action requires the meshStack workflow trigger parameters to be present in the GitHub event payload:
44+
45+
- `buildingBlockRunUrl` (required): URL to fetch the building block run object from the meshStack API
46+
- `buildingBlockRun` (optional, legacy): Base64-encoded building block run object (alternative to `buildingBlockRunUrl`)
3047

48+
These parameters are automatically provided by meshStack when it triggers your workflow via `workflow_dispatch`.
3149

32-
### Example Usage
50+
## Example Usage
3351

3452
```yaml
35-
- name: Setup meshStack bbrun
36-
id: setup-meshstack-auth
37-
uses: meshcloud/actions-register-source@main
38-
with:
39-
client_id: ${{ vars.BUILDINGBLOCK_API_CLIENT_ID }}
40-
key_secret: ${{ secrets.BUILDINGBLOCK_API_KEY_SECRET }}
41-
steps: |
42-
[
43-
{ "id": "terraform-plan", "displayName": "terraform plan" },
44-
]
45-
46-
- name: Terragrunt plan
47-
id: terraform-plan
48-
run: terraform plan -var="resource_group_name=${{ steps.setup-meshstack-auth.outputs.resource_group_name }}" -out=tfplan
49-
50-
51-
- name: Send status on plan
52-
if: ${{ steps.terraform-plan.outcome == 'success' }}
53-
uses: meshcloud/actions-send-status@main
54-
with:
55-
step_id: "terraform-plan"
56-
status: ${{ steps.terraform-plan.outcome == 'success' && 'SUCCEEDED' || 'FAILED' }}
57-
user_message: ${{ steps.terraform-plan.outcome == 'success' && 'Successful plan Terraform configuration.' || 'Failed to plan Terraform configuration.' }}
58-
system_message: ${{ steps.terraform-plan.outcome == 'success' && 'Successful plan Terraform configuration.' || 'Failed to plan Terraform configuration.' }}```
53+
name: Deploy Building Block
54+
55+
on:
56+
workflow_dispatch:
57+
inputs:
58+
buildingBlockRunUrl:
59+
description: "URL to fetch the Building Block Run Object from"
60+
required: true
61+
62+
jobs:
63+
deploy:
64+
runs-on: ubuntu-latest
65+
steps:
66+
- name: Checkout Code
67+
uses: actions/checkout@v4
68+
69+
- name: Setup meshStack auth
70+
id: setup-meshstack-auth
71+
uses: meshcloud/actions-meshstack-auth@v2
72+
with:
73+
base_url: ${{ vars.MESHSTACK_BASE_URL }}
74+
client_id: ${{ vars.BUILDINGBLOCK_API_CLIENT_ID }}
75+
key_secret: ${{ secrets.BUILDINGBLOCK_API_KEY_SECRET }}
76+
77+
- name: Register building block source
78+
id: register-source
79+
uses: meshcloud/actions-register-source@v2
80+
with:
81+
steps: |
82+
[
83+
{ "id": "terraform-plan", "displayName": "Terraform Plan" },
84+
{ "id": "terraform-apply", "displayName": "Terraform Apply" }
85+
]
86+
87+
- name: Terraform plan
88+
id: terraform-plan
89+
run: terraform plan -var="resource_group_name=${{ steps.register-source.outputs.resource_group_name }}" -out=tfplan
90+
91+
- name: Send status on plan
92+
uses: meshcloud/actions-send-status@v2
93+
with:
94+
step_id: terraform-plan
95+
step_status: SUCCEEDED
96+
97+
- name: Terraform apply
98+
id: terraform-apply
99+
run: terraform apply tfplan
100+
101+
- name: Send status on apply
102+
uses: meshcloud/actions-send-status@v2
103+
with:
104+
step_id: terraform-apply
105+
step_status: SUCCEEDED
106+
107+
```

action.yml

Lines changed: 3 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,15 @@
1-
name: 'Setup Meshstack Authentication'
2-
description: 'Authenticates with Meshstack and sets up environment variables'
1+
name: 'Register Building Block Source'
2+
description: 'Registers a building block source with meshStack'
33
inputs:
44
steps:
55
description: 'The steps to register'
66
required: true
77
type: string
8-
client_id:
9-
description: 'The client ID for authentication'
10-
required: true
11-
type: string
12-
key_secret:
13-
description: 'The key secret for authentication'
14-
required: true
15-
type: string
168
outputs:
179
token_file:
1810
description: 'Path to the file containing the authentication token'
1911
runs:
20-
using: 'node20'
12+
using: 'node24'
2113
main: 'dist/main/index.js'
2214
post: 'dist/cleanup/index.js'
2315

dist/cleanup/index.js

Lines changed: 18 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -25663,42 +25663,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
2566325663
__setModuleDefault(result, mod);
2566425664
return result;
2566525665
};
25666-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
25667-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
25668-
return new (P || (P = Promise))(function (resolve, reject) {
25669-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
25670-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
25671-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
25672-
step((generator = generator.apply(thisArg, _arguments || [])).next());
25673-
});
25674-
};
2567525666
Object.defineProperty(exports, "__esModule", ({ value: true }));
2567625667
const core = __importStar(__nccwpck_require__(2186));
2567725668
const fs = __importStar(__nccwpck_require__(7147));
2567825669
const path = __importStar(__nccwpck_require__(1017));
2567925670
const os = __importStar(__nccwpck_require__(2037));
25680-
function cleanup() {
25681-
return __awaiter(this, void 0, void 0, function* () {
25682-
try {
25683-
const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
25684-
const tokenFilePath = path.join(tempDir, 'meshstack_token.json');
25685-
if (fs.existsSync(tokenFilePath)) {
25686-
fs.unlinkSync(tokenFilePath);
25687-
core.info(`Deleted token file: ${tokenFilePath}`);
25688-
}
25689-
else {
25690-
core.info(`Token file does not exist: ${tokenFilePath}`);
25691-
}
25671+
async function cleanup() {
25672+
try {
25673+
const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
25674+
const tokenFilePath = path.join(tempDir, 'meshstack_token.json');
25675+
if (fs.existsSync(tokenFilePath)) {
25676+
fs.unlinkSync(tokenFilePath);
25677+
core.info(`Deleted token file: ${tokenFilePath}`);
2569225678
}
25693-
catch (error) {
25694-
if (error instanceof Error) {
25695-
core.setFailed(error.message);
25696-
}
25697-
else {
25698-
core.setFailed('An unknown error occurred during cleanup');
25699-
}
25679+
else {
25680+
core.info(`Token file does not exist: ${tokenFilePath}`);
2570025681
}
25701-
});
25682+
}
25683+
catch (error) {
25684+
if (error instanceof Error) {
25685+
core.setFailed(error.message);
25686+
}
25687+
else {
25688+
core.setFailed('An unknown error occurred during cleanup');
25689+
}
25690+
}
2570225691
}
2570325692
cleanup();
2570425693

0 commit comments

Comments
 (0)