|
1 | | -# Register Source GitHub Action |
| 1 | +# meshStack Register Source Action |
2 | 2 |
|
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. |
4 | 5 |
|
5 | | -### Overview |
| 6 | +## Overview |
6 | 7 |
|
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. |
8 | 9 |
|
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. |
10 | 11 |
|
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 |
12 | 13 |
|
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: |
14 | 15 |
|
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 |
16 | 19 |
|
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 |
18 | 21 |
|
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) |
20 | 25 |
|
21 | | -### Inputs |
| 26 | +## Building Block Inputs |
22 | 27 |
|
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 }}`. |
26 | 29 |
|
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 |
28 | 37 |
|
29 | 38 | - `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`) |
30 | 47 |
|
| 48 | +These parameters are automatically provided by meshStack when it triggers your workflow via `workflow_dispatch`. |
31 | 49 |
|
32 | | -### Example Usage |
| 50 | +## Example Usage |
33 | 51 |
|
34 | 52 | ```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 | +``` |
0 commit comments