Skip to content

Commit

Permalink
Update README.md improve description
Browse files Browse the repository at this point in the history
  • Loading branch information
pablovilas authored Oct 8, 2023
1 parent a7b48ba commit 95b83d3
Showing 1 changed file with 112 additions and 50 deletions.
162 changes: 112 additions & 50 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,78 +1,140 @@
# Nullplatform Metadata GitHub Action
<h2 align="center">
<a href="https://httpie.io" target="blank_">
<img height="100" alt="nullplatform" src="https://nullplatform.com/favicon/android-chrome-192x192.png" />
</a>
<br>
<br>
Nullplatform Metadata GitHub Action
<br>
</h2>

<p align="center">
<a href="https://github.com/nullplatform/github-action-metadata/actions"><img alt="javscript-action status" src="https://github.com/nullplatform/github-action-metadata/workflows/units-test/badge.svg"></a>
</p>
The "Nullplatform Metadata" GitHub Action allows you to query Nullplatform metadata, making it easier to manage various resources within the Nullplatform ecosystem. Whether you need to retrieve information about applications, builds, assets, releases, or deployments, this action provides a simple and automated way to do so.

You can use the GitHub Action to automate the login process on Nullplatform.
## Table of Contents

## Code
- [Inputs](#inputs)
- [Outputs](#outputs)
- [Usage](#usage)
- [Use Case 1: Query Application Metadata](#use-case-1-query-application-metadata)
- [Use Case 2: Query Build Metadata](#use-case-2-query-build-metadata)
- [License](#license)

Install the dependencies
## Inputs

```bash
npm install
```
### `resource`

Run the tests :heavy_check_mark:
- **Description**: Specifies the Nullplatform resource to query.
- **Options**: Choose from: `application`, `build`, `asset`, `release`, `deployment`.
- **Required**: Yes

```bash
$ npm test
### Inputs for application resource

PASS ./index.test.js
✓ throws invalid credentials (3ms)
✓ logins into nullplatform (504ms)
✓ other test (95ms)
...
```
#### `name`

## Change action.yml
- **Description**: Allows you to specify the name of the application for filtering the query.
- **Required**: No

The action.yml defines the inputs and output for your action.
#### `status`

Update the action.yml with your name, description, inputs and outputs for your action.
- **Description**: Specifies the application status to filter the query.
- **Required**: No

See the [documentation](https://help.github.com/en/articles/metadata-syntax-for-github-actions)
#### `code-repository-url`

## Change the Code
- **Description**: Specifies the URL of the application's code repository.
- **Required**: No

Most toolkit and CI/CD operations involve async operations so the action is run in an async function.
#### `code-repository-application-path`

```javascript
const core = require('@actions/core');
...
- **Description**: Specifies the path of the application within the code repository.
- **Required**: No

async function run() {
try {
...
}
catch (error) {
core.setFailed(error.message);
}
}
### Inputs for other resources

run()
```
Please note that inputs for `build`, `asset`, `release`, and `deployment` are not yet supported. Support for these resources is planned for future releases.

See the [toolkit documentation](https://github.com/actions/toolkit/blob/master/README.md#packages) for the various packages.
## Outputs

## Package for distribution
### `metadata`

- **Description**: Stores the retrieved nullplatform metadata, which can be further utilized in your workflow.

## Usage

Update version in ``package.json`` file and then run:
Here are some common use cases for this GitHub Action:

```bash
npm run update:version
### Use Case 1: Query Application Metadata

```yaml
name: Query Application Metadata
on:
workflow_dispatch:

jobs:
query-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4

- name: Login to Nullplatform
id: login-nullplatform
uses: nullplatform/nullplatform-login-action@v1
with:
api-key: ${{ secrets.NULLPLATFORM_API_KEY }}

- name: Query Nullplatform Application
id: query-application
uses: nullplatform/nullplatform-metadata-action@v1
with:
resource: application
name: my-app-name
status: active

- name: Use Metadata
run: |
echo "Application Metadata:"
echo "${{ steps.query-application.outputs.metadata }}"
```
## Usage
In this example, the GitHub Action first logs in to Nullplatform using the "nullplatform-login-action" with the API key `NULLPLATFORM_API_KEY` stored in GitHub secrets before querying nullplatform metadata for an application.

You can now consume the action by referencing the v1 branch
### Use Case 2: Query Build Metadata

```yaml
uses: nullplatform/github-action-metadata@v1
with:
resource: application
name: ${{ env.APP_NAME }}
name: Query Build Metadata
on:
push:
branches:
- main
jobs:
query-metadata:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Login to Nullplatform
id: login-nullplatform
uses: nullplatform/nullplatform-login-action@v1
with:
api-key: ${{ secrets.NULLPLATFORM_API_KEY }}
- name: Query Nullplatform Build
id: query-build
uses: nullplatform/nullplatform-metadata-action@v1
with:
resource: build
- name: Use Metadata
run: |
echo "Build Metadata:"
echo "${{ steps.query-build.outputs.metadata }}"
```

See the [actions tab](https://github.com/actions/javascript-action/actions) for runs of this action! :rocket:
In this example, the GitHub Action logs in to nullplatform using the "nullplatform-login-action" with the API key `NULLPLATFORM_API_KEY` stored in GitHub secrets before querying nullplatform metadata for builds triggered on the `main` branch.

## License

This GitHub Action is licensed under the [MIT License](LICENSE).

0 comments on commit 95b83d3

Please sign in to comment.