Skip to content

Commit 23ef1b4

Browse files
committed
Initial import
1 parent ffc9b7a commit 23ef1b4

File tree

3 files changed

+75
-2
lines changed

3 files changed

+75
-2
lines changed

README.md

Lines changed: 45 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,45 @@
1-
# import-github-action
2-
GitHub Action for importing API specs in Microcks
1+
## GitHub Action for importing API spec in Microcks
2+
3+
### What is it?
4+
5+
This is a GitHub Action you may use in your Workflow to import into Microcks some API specification files. This allow keeping your API definitions, mocks and tests up-to-date into Microcks.. This action is basically a wrapper around the [Microcks CLI](https://github.com/microcks/microcks-cli) and provides the same configuration capabilities.
6+
7+
The `import` command of the CLI just need 1 argument:
8+
* `<specificationFile1[:primary],specificationFile2[:primary]>` : Comma separated list of API specs to import with flag telling if it's a primary artifact. Example: `'specs/my-openapi.yaml:true,specs/my-postmancollection.json:false'`
9+
10+
With a bunch of mandatory flags:
11+
* `--microcksURL` for the Microcks API endpoint,
12+
* `--keycloakClientId` for the Keycloak Realm Service Account ClientId,
13+
* `--keycloakClientSecret` for the Keycloak Realm Service Account ClientSecret.
14+
15+
### How to use it?
16+
17+
Obviously we can find this action with [GitHub Actions Marketplace](https://github.com/marketplace?type=actions) :wink:
18+
19+
You may add the Action to your Workflow directly from the GitHub UI.
20+
21+
![marketplace](./assets/marketplace.png)
22+
23+
#### Step 1 - Configure the GitHub action
24+
25+
```yaml
26+
name: my-workflow
27+
on: [push]
28+
jobs:
29+
my-job:
30+
runs-on: ubuntu-latest
31+
environment: Development
32+
steps:
33+
- uses: microcks/import-github-action@v1
34+
with:
35+
specificationFiles: 'samples/weather-forecast-openapi.yml:true,samples/weather-forecast-postman.json:false'
36+
microcksURL: 'https://microcks.apps.acme.com/api/'
37+
keycloakClientId: ${{ secrets.MICROCKS_SERVICE_ACCOUNT }}
38+
keycloakClientSecret: ${{ secrets.MICROCKS_SERVICE_ACCOUNT_CREDENTIALS }}
39+
```
40+
41+
#### Step 2 - Configure the Secrets
42+
43+
As you probably saw just above, we do think it's a best practice to use GitHub Secrets (general or tied to `Environment` like in the example) to hold the Keycloak credentials (client Id and Secret). See below the Secrets configuration we've used for the example:
44+
45+
![secret configuration](./assets/secrets.png)

action.yml

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
name: 'Microcks Import GitHub action'
2+
author: 'Microcks.io'
3+
description: 'Import API specifications into Microcks'
4+
inputs:
5+
specificationFiles:
6+
description: "<specificationFile1[:primary],specificationFile2[:primary]>: Comma separated list of API specs to import with flag telling if it's a primary artifact. Example: 'specs/my-openapi.yaml:true,specs/my-postmancollection.json:false'"
7+
required: true
8+
microcksURL:
9+
description: 'Microcks instance API endpoint'
10+
required: true
11+
keycloakClientId:
12+
description: 'Keycloak Realm Service Account ClientId'
13+
required: true
14+
keycloakClientSecret:
15+
description: 'Keycloak Realm Service Account ClientSecret'
16+
required: true
17+
runs:
18+
using: 'docker'
19+
image: 'docker://quay.io/microcks/microcks-cli:0.4.0'
20+
entrypoint: '/usr/bin/bash'
21+
args:
22+
- '-c'
23+
- >-
24+
microcks-cli import '${{ inputs.specificationFiles }}' \
25+
--microcksURL=${{ inputs.microcksURL }} \
26+
--keycloakClientId=${{ inputs.keycloakClientId }} --keycloakClientSecret=${{ inputs.keycloakClientSecret }} \
27+
--insecure
28+
branding:
29+
icon: 'upload-cloud'
30+
color: 'blue'

assets/secrets.png

299 KB
Loading

0 commit comments

Comments
 (0)