-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
DTSPO-13135 OpenAPI reusable workflow (#1)
- Loading branch information
Showing
4 changed files
with
74 additions
and
1 deletion.
There are no files selected for viewing
Validating CODEOWNERS rules …
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
* @hmcts/platform-operations |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
{ | ||
"$schema": "https://docs.renovatebot.com/renovate-schema.json", | ||
"schedule": "after 7am and before 11am every weekday", | ||
"extends": [ | ||
"config:base" | ||
], | ||
"labels": [ | ||
"dependencies" | ||
], | ||
"platformAutomerge": true, | ||
"automerge": true, | ||
"automergeType": "pr" | ||
} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: Publish OpenAPI Spec | ||
|
||
on: | ||
workflow_call: | ||
inputs: | ||
test_to_run: | ||
required: true | ||
type: string | ||
description: The full path to the test to run, e.g. uk.gov.hmcts.reform.myapp.openapi.OpenAPIPublisherTest | ||
java_version: | ||
required: true | ||
type: string | ||
secrets: | ||
SWAGGER_PUBLISHER_API_TOKEN: | ||
required: true | ||
description: GitHub API token that can publish to the cnp-api-docs repository | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- name: Set up JDK ${{ inputs.java_version }} | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: ${{ inputs.java_version }} | ||
distribution: 'temurin' | ||
cache: 'gradle' | ||
- name: Run OpenAPI Publisher | ||
run: ./gradlew integration --tests ${{ inputs.test_to_run }} | ||
- name: Commit to repository | ||
run: | | ||
mkdir openapi-staging | ||
cd openapi-staging | ||
git init | ||
git config user.email "[email protected]" | ||
git config user.name "HMCTS Platform Operations" | ||
git remote add upstream https://apitoken:${{ secrets.SWAGGER_PUBLISHER_API_TOKEN }}@github.com/hmcts/cnp-api-docs.git | ||
git pull upstream master | ||
repo=`echo "$GITHUB_REPOSITORY" | cut -f2- -d/` | ||
echo "$(cat /tmp/openapi-specs.json)" > "docs/specs/$repo.json" | ||
git add "docs/specs/$repo.json" | ||
# Only commit and push if we have changes | ||
git diff --quiet && git diff --staged --quiet || (git commit -m "Update spec for $repo#${GITHUB_SHA:7}"; git push --set-upstream upstream master) |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1,16 @@ | ||
# github-reusable-workflows | ||
# workflow-publish-openapi-spec | ||
|
||
This reusuable workflow can be used to published OpenAPI specs to the [HMCTS CNP API repository](https://github.com/hmcts/cnp-api-docs). | ||
|
||
## Usage | ||
|
||
There's a workflow template at https://github.com/hmcts/.github/blob/master/workflow-templates/publish-openapi.yml. | ||
|
||
To use it from your repository go to: | ||
|
||
Actions -> New workflow | ||
|
||
Click Configure under "Publish OpenAPI specs" | ||
|
||
Update the `test_to_run` input variable | ||
Check the `java_version` variable is right for your project |