From f7f4e2886405fbf17cf2f28883ef1852a061bd10 Mon Sep 17 00:00:00 2001 From: API Evolution Management Service CI Date: Wed, 10 May 2023 04:03:29 +0000 Subject: [PATCH] Publish new version from API Evolution Management Service CI (https://circleci.com/gh/fernandomrtnz/api-evolution-management-service/155) --- .github/workflows/main.yml | 24 ++++++++++++++++++ README.md | 35 +++++++++++++++++++++++++ action.yml | 52 ++++++++++++++++++++++++++++++++++++++ 3 files changed, 111 insertions(+) create mode 100644 .github/workflows/main.yml create mode 100644 README.md create mode 100644 action.yml diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml new file mode 100644 index 0000000..2eeac07 --- /dev/null +++ b/.github/workflows/main.yml @@ -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.2.0-beta + release_name: Release v1.2.0-beta + draft: false + prerelease: false diff --git a/README.md b/README.md new file mode 100644 index 0000000..66a8723 --- /dev/null +++ b/README.md @@ -0,0 +1,35 @@ +# 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. + +## 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: fernandomrtnz/gh-action-test@v1.0.0-beta + with: + file_path: openapi.yml + access_token: ${{ secrets.APIEMS_ACCESS_TOKEN }} +``` \ No newline at end of file diff --git a/action.yml b/action.yml new file mode 100644 index 0000000..ff60224 --- /dev/null +++ b/action.yml @@ -0,0 +1,52 @@ +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: Check for breaking changes + shell: bash + 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 -s -o /dev/null -X POST \ + -w "%{http_code}" \ + "${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 "API Evolution Management Service returned an ${response} HTTP status code." + + if [ "${response}" -eq 400 ]; then + echo "Breaking changes detected!" + exit 1 + else + echo "No breaking changes detected." + fi + else + echo "File not found in either main or current branch." + fi