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
42 changes: 42 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
name: CI Tests

on:
push:
branches: [ main, develop, 'feature/**' ]
pull_request:
branches: [ main, develop ]

jobs:
build:
runs-on: ubuntu-latest

strategy:
matrix:
node-version: [24.x]

steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'

- name: Install dependencies
run: npm ci

- name: Run tests
run: npm test

- name: Build action
run: npm run build

- name: Check if dist/ is up to date
run: |
if [ -n "$(git status --porcelain dist/)" ]; then
echo "dist/ directory is not up to date. Please run 'npm run build' and commit the changes."
git status --porcelain dist/
exit 1
fi
52 changes: 0 additions & 52 deletions .github/workflows/release.yml

This file was deleted.

20 changes: 0 additions & 20 deletions .github/workflows/test.yml

This file was deleted.

58 changes: 41 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,35 +1,59 @@
# MeshStack Auth Action
# meshStack Auth Action

This action authenticates to meshStack API.
This GitHub Action authenticates to the meshStack API to enable building block automation workflows as well as other API interactions with meshStack.

### Overview
## Overview

This GitHub Action is designed to authenticate against the Meshfed API. It helps you obtain an access token using client credentials, which can then be used to interact with the Meshfed API securely. This action simplifies the process of obtaining and managing authentication tokens for your workflows.
This action helps you obtain an access token using client credentials, which can then be used to interact with the meshStack API securely. This action simplifies the process of obtaining and managing authentication tokens for your workflows.

### API Documentation
## Related Actions

For more information about the Meshfed API, please refer to the [Meshfed API Documentation](https://docs.meshcloud.io/api/index.html).
This action is part of a suite of GitHub Actions for meshStack building block automation:

- **[actions-meshstack-auth](https://github.com/meshcloud/actions-meshstack-auth)** (this action) - Authenticates to the meshStack API
- **[actions-register-source](https://github.com/meshcloud/actions-register-source)** - Registers building block sources and steps with meshStack
- **[actions-send-status](https://github.com/meshcloud/actions-send-status)** - Sends building block step status updates to meshStack

### Inputs
## Documentation

For more information about meshStack building blocks and GitHub Actions integration, refer to:
- [meshStack GitHub Actions Integration](https://docs.meshcloud.io/integrations/github/github-actions/)
- [meshStack API Documentation](https://docs.meshcloud.io/api/index.html)

## Inputs

- `base_url` (required): meshStack API endpoint.
- `client_id` (required): The client ID for the API.
- `key_secret` (required): The key secret for the API.

### Outputs
## Outputs

- `token_file`: Path to the file containing the authentication token


### Example Usage
## Example Usage

```yaml
- name: Setup meshStack bbrun
id: setup-meshstack-auth
uses: meshcloud/actions-meshstack-auth@v0.0.1
with:
base_url: ${{ vars.BUILDINGBLOCK_API_BASE_URL }}
client_id: ${{ vars.BUILDINGBLOCK_API_CLIENT_ID }}
key_secret: ${{ secrets.BUILDINGBLOCK_API_KEY_SECRET }}
name: Deploy Building Block

on:
workflow_dispatch:
inputs:
buildingBlockRunUrl:
description: "URL to fetch the Building Block Run Object from"
required: true

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- name: Checkout Code
uses: actions/checkout@v4

- name: Setup meshStack auth
id: setup-meshstack-auth
uses: meshcloud/actions-meshstack-auth@v2
with:
base_url: ${{ vars.MESHSTACK_BASE_URL }}
client_id: ${{ vars.MESHSTACK_API_CLIENT_ID }}
key_secret: ${{ secrets.MESHSTACK_API_KEY_SECRET }}
```
8 changes: 4 additions & 4 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
name: 'Setup Meshstack Authentication'
description: 'Authenticates with Meshstack and sets up environment variables'
name: 'Setup meshStack Authentication'
description: 'Authenticates with meshStack and stores authentication token'
inputs:
base_url:
description: 'The URL of the Meshstack instance'
description: 'The URL of the meshStack instance'
required: true
type: string
client_id:
Expand All @@ -17,7 +17,7 @@ outputs:
token_file:
description: 'Path to the file containing the authentication token'
runs:
using: 'node20'
using: 'node24'
main: 'dist/main/index.js'
post: 'dist/cleanup/index.js'

Expand Down
47 changes: 18 additions & 29 deletions dist/cleanup/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25663,42 +25663,31 @@ var __importStar = (this && this.__importStar) || function (mod) {
__setModuleDefault(result, mod);
return result;
};
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
return new (P || (P = Promise))(function (resolve, reject) {
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
Object.defineProperty(exports, "__esModule", ({ value: true }));
const core = __importStar(__nccwpck_require__(2186));
const fs = __importStar(__nccwpck_require__(7147));
const path = __importStar(__nccwpck_require__(1017));
const os = __importStar(__nccwpck_require__(2037));
function cleanup() {
return __awaiter(this, void 0, void 0, function* () {
try {
const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
const tokenFilePath = path.join(tempDir, 'meshstack_token.json');
if (fs.existsSync(tokenFilePath)) {
fs.unlinkSync(tokenFilePath);
core.info(`Deleted token file: ${tokenFilePath}`);
}
else {
core.info(`Token file does not exist: ${tokenFilePath}`);
}
async function cleanup() {
try {
const tempDir = process.env.RUNNER_TEMP || os.tmpdir();
const tokenFilePath = path.join(tempDir, 'meshstack_token.json');
if (fs.existsSync(tokenFilePath)) {
fs.unlinkSync(tokenFilePath);
core.info(`Deleted token file: ${tokenFilePath}`);
}
catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
else {
core.setFailed('An unknown error occurred during cleanup');
}
else {
core.info(`Token file does not exist: ${tokenFilePath}`);
}
});
}
catch (error) {
if (error instanceof Error) {
core.setFailed(error.message);
}
else {
core.setFailed('An unknown error occurred during cleanup');
}
}
}
cleanup();

Expand Down
Loading