Skip to content

Commit

Permalink
Publish new version from API Evolution Management Service CI (https:/…
Browse files Browse the repository at this point in the history
  • Loading branch information
API Evolution Management Service CI committed May 7, 2023
0 parents commit 9b1fd8e
Show file tree
Hide file tree
Showing 3 changed files with 139 additions and 0 deletions.
24 changes: 24 additions & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Publish

on:
push:
branches:
- main

jobs:
publish:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v2

- name: Bump version and create a release
id: create_release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.CREATE_RELEASE_TOKEN }}
with:
tag_name: v1.0.0-beta
release_name: Release v1.0.0-beta
draft: false
prerelease: false
66 changes: 66 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
# API Evolution Check Action

This GitHub Action checks for breaking changes in your API specifications by comparing the current branch's API specification file with the one in the main branch. It requires a file path to your OpenAPI specification file and an access token for the API Evolution Management Service.

## Usage

Add the following workflow configuration (e.g., `.github/workflows/api_check.yml`) to your repository:

```yaml
name: API Evolution Check

on:
push:
branches:
- main
- '*' # This will match any branch

jobs:
api_evolution_check:
runs-on: ubuntu-latest

steps:
- name: Run API Evolution Check
uses: <your-github-username>/gh-action-test-tostones@<tag-or-branch>
with:
file_path: path/to/api/specification/file.yaml
access_token: ${{ secrets.API_EVOLUTION_ACCESS_TOKEN }}
```
Replace `<your-github-username>` with the actual GitHub username and `<tag-or-branch>` with the desired version (e.g., `v1` or `main`) of the action. Also, replace `path/to/api/specification/file.yaml` with the path to your OpenAPI specification file.

For the `access_token` input, use the `secrets` context to store and retrieve the API Evolution Management Service access token securely. Create a secret in your repository (e.g., named `API_EVOLUTION_ACCESS_TOKEN`) and store the access token there.

## Inputs

| Name | Description | Required |
|---------------|------------------------------------------------------|----------|
| `file_path` | Path to the API specification file you want to compare | Yes |
| `access_token`| API Evolution Management Service access token | Yes |

## Example

This example demonstrates how to use the action in a workflow:

```yaml
name: API Evolution Check
on:
push:
branches:
- main
- '*' # This will match any branch
jobs:
api_evolution_check:
runs-on: ubuntu-latest
steps:
- name: Run API Evolution Check
uses: <your-github-username>/gh-action-test-tostones@v1
with:
file_path: api/openapi.yaml
access_token: ${{ secrets.API_EVOLUTION_ACCESS_TOKEN }}
```

Replace `<your-github-username>` with the actual GitHub username and `v1` with the desired version of the action.
49 changes: 49 additions & 0 deletions action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: gh-action-test-tostones
description: "Check for breaking changes in API specifications"

inputs:
file_path:
description: "Path to the API specification that you want to compare"
required: true
access_token:
description: "API Evolution Management Service access token"
required: true

runs:
using: "composite"
steps:
- name: Checkout main branch
uses: actions/checkout@v2
with:
ref: main
path: main

- name: Checkout current branch
uses: actions/checkout@v2
with:
path: current

- name: Debug
run: |
cat "${GITHUB_WORKSPACE}/main/${{ inputs.file_path }}"
cat "${GITHUB_WORKSPACE}/current/${{ inputs.file_path }}"
- name: Check for breaking changes
run: |
before_file_path="${GITHUB_WORKSPACE}/main/${{ inputs.file_path }}"
after_file_path="${GITHUB_WORKSPACE}/current/${{ inputs.file_path }}"
api_url="https://qlq2x2wbi74vc4h6hvjgc5szky0phost.lambda-url.us-east-2.on.aws/"
if [ -f "${before_file_path}" ] && [ -f "${after_file_path}" ]; then
response=$(curl -X POST \
"${api_url}" \
-H "Content-Type: multipart/form-data" \
-H "Authorization: Bearer ${{ inputs.access_token }}" \
-F "before=@${before_file_path}" \
-F "after=@${after_file_path}")
echo "Upload response: ${response}"
else
echo "File not found in either main or current branch."
fi
shell: bash

0 comments on commit 9b1fd8e

Please sign in to comment.