Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

set up actions workflow and config documentation #55

Merged
merged 4 commits into from
Aug 18, 2020

Conversation

idoqo
Copy link
Collaborator

@idoqo idoqo commented Aug 17, 2020

This adds the Github Actions workflow for publishing OpenAPI definitions to SwaggerHub and deleting them. It also includes a documentation for the config route so that CI has something to work with.

To make it work, we will need a SwaggerHub account, and a Github secret named SGH_TOKEN which contains the SwaggerHub API token.

Copy link
Contributor

@litleleprikon litleleprikon left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For the whole PR: let's name the variables with lower case as it usually done.


- name: remove spec from swaggerhub
env:
AUTH_TOKEN: ${{secrets.SGH_TOKEN}}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

May we name it SWAGGERHUB_TOKEN? As for me it will be more clear for anyone who will read action file and configure secrets.

version=${RELEASE_VERSION}
version=`echo $version|sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "removing API spec: ${version} from swaggerhub"
curl -X DELETE "https://api.swaggerhub.com/apis/idoko/moira-alert/${version}" -H "content-type: application/yaml" -H "Authorization: ${AUTH_TOKEN}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This URL should be used https://app.swaggerhub.com/organizations/Moira. I actually think that it will be better to move main part of URL to variable.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it to be a variable under the env: section, not sure if that was what you meant anyway.

node-version: '14'
- run: npm install -g swagger-cli
- run: make spec
- run: pwd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it debugging output?

- uses: actions/checkout@v2
- name: set output for versioning
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Probably we should use here ' to prevent substitution of * with glob?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Added double quotes now.

echo "Uploading OpenAPI spec v ${RELEASE_VERSION}"
pwd
def=`cat ./build/openapi.yml`
curl -d "$def" "https://api.swaggerhub.com/apis/idoko/moira-alert/?isPrivate=false&version=${version}&oas=3.0.0&force=true" -H "content-type: application/yaml" -H "Authorization: ${AUTH_TOKEN}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same wrong URL

version=${RELEASE_VERSION}
version=`echo $version|sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "Uploading OpenAPI spec v ${RELEASE_VERSION}"
pwd
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Also seems as a debugging output

version=${RELEASE_VERSION}
version=`echo $version|sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "removing API spec: ${version} from swaggerhub"
curl -X DELETE "https://api.swaggerhub.com/apis/idoko/moira-alert/${version}" -H "content-type: application/yaml" -H "Authorization: ${AUTH_TOKEN}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I'd have to wait for the swaggerhub account to be ready before changing the URL. What do you think?

- uses: actions/checkout@v2
- name: set output for versioning
id: vars
run: echo ::set-output name=tag::${GITHUB_REF#refs/*/}
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Right. Added double quotes now.

version=${RELEASE_VERSION}
version=`echo $version|sed 's#[^a-zA-Z0-9_\.\-]#_#g'`
echo "removing API spec: ${version} from swaggerhub"
curl -X DELETE "https://api.swaggerhub.com/apis/idoko/moira-alert/${version}" -H "content-type: application/yaml" -H "Authorization: ${AUTH_TOKEN}"
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've updated it to be a variable under the env: section, not sure if that was what you meant anyway.

@litleleprikon litleleprikon merged commit 71e5977 into moira-alert:master Aug 18, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants