Update send-to-discovery.yml #161
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Sync Discovered API with ApiConnect | |
on: [pull_request, workflow_dispatch, push] | |
env: | |
API_HOST: d-j02.apiconnect.dev.automation.ibm.com | |
# platform_api_prefix is not required to change for ApiConnect on Cloud | |
PLATFORM_API_PREFIX: platform-api | |
PROVIDER_ORG: niraimathi | |
API_FILES: gmail-api.json | |
#API_FILES: gmail-api.json,mit-api.json,gmail-api.yaml,APIfolder/uber-api.json | |
#API_FOLDERS: APIfolder | |
jobs: | |
check_changes_job: | |
runs-on: 'ubuntu-20.04' | |
# Declare outputs for next jobs | |
outputs: | |
action_changed: ${{ steps.check_workflow_changed.outputs.action_updates }} | |
changed_filename: ${{ steps.changed_filename.outputs.api_file }} | |
apifiles_env: ${{ steps.changed_filename.outputs.apifiles_env }} | |
folder_changed: ${{ steps.check_apifolders_changed.outputs.folder_updates }} | |
steps: | |
- uses: actions/checkout@v4 | |
with: | |
fetch-depth: 2 | |
- name: Check Workflow changed | |
id: check_workflow_changed | |
run: | | |
echo "action_updates=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.sha }} | grep discover-api.yml | xargs)" >> $GITHUB_OUTPUT | |
- name: Changed API File Name | |
id: changed_filename | |
run: | | |
echo "api_file=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.sha }} | xargs)" >> $GITHUB_OUTPUT | |
echo "apifiles_env=$(echo $API_FILES)" >> $GITHUB_OUTPUT | |
- name: Check API Folders changed | |
id: check_apifolders_changed | |
run: | | |
echo "folder_updates=$(git diff --name-only --diff-filter=ACMRT ${{ github.event.before }} ${{ github.sha }} | grep $API_FOLDERS | xargs)" >> $GITHUB_OUTPUT | |
run-discovery: | |
runs-on: ubuntu-latest | |
needs: [ check_changes_job ] | |
if: ${{ (contains(needs.check_changes_job.outputs.apifiles_env,needs.check_changes_job.outputs.changed_filename)) || (needs.check_changes_job.outputs.action_changed) || (needs.check_changes_job.outputs.folder_changed) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: ibm-apiconnect/apic-discovery-action@main | |
id: discover-apis | |
with: | |
api_host: ${{ env.API_HOST }} | |
platform_api_prefix: ${{ env.PLATFORM_API_PREFIX }} | |
provider_org: ${{ env.PROVIDER_ORG }} | |
api_key: ${{ secrets.apicApikey }} | |
if: env.API_FILES | |
api_files: ${{ env.API_FILES }} | |
else if: env.API_FOLDERS | |
api_folders: ${{ env.API_FOLDERS }} | |
resync_check: ${{ needs.check_changes_job.outputs.action_changed && true || false }} | |
- name: Display the action-result | |
run: | | |
echo "Result of the action: ${{ steps.discover-apis.outputs.action-result }}" |