Skip to content

Commit 5be2d23

Browse files
fix: FOAS Prod GH Action creates wrong issue (#125)
1 parent ee7f25c commit 5be2d23

File tree

5 files changed

+25
-9
lines changed

5 files changed

+25
-9
lines changed

.github/workflows/optional-spec-validations.yml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@ jobs:
3232
github-token: ${{ secrets.api_bot_pat }}
3333
run-id: ${{ github.run_id }}
3434
- name: Validate the FOAS can be used to generate Postman collection
35+
id: spectral-validation
3536
env:
3637
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
3738
run: |
@@ -41,7 +42,7 @@ jobs:
4142
npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint ./tmp/collection.json --ruleset=./validation/spectral.yaml
4243
popd
4344
- name: Create Issue
44-
if: ${{ failure() }}
45+
if: ${{ failure() && steps.spectral-validation.outcome == 'failure' }}
4546
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
4647
env:
4748
target_env: ${{ inputs.env }}

.github/workflows/release-spec-prod.yml

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -65,14 +65,15 @@ jobs:
6565
working-directory: tools/cli
6666
run: make build
6767
- name: Run foascli split command
68+
id: split
6869
run: |
6970
./tools/cli/bin/foascli split -s openapi-foas.json --env prod -o ./openapi/v2/openapi.json
7071
cp -rf "openapi-foas.json" "./openapi/v2.json"
7172
7273
./tools/cli/bin/foascli split -s openapi-foas.yaml --env prod -o ./openapi/v2/openapi.yaml
7374
cp -rf "openapi-foas.yaml" "./openapi/v2.yaml"
7475
- name: Create Issue
75-
if: ${{ failure() }}
76+
if: ${{ failure() && steps.split.outcome == 'failure' }}
7677
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
7778
with:
7879
labels: failed-release
@@ -82,6 +83,7 @@ jobs:
8283

8384
- name: Create Pull Request
8485
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
86+
id: create-pr
8587
with:
8688
token: ${{ secrets.GITHUB_TOKEN }}
8789
title: "release: (prod) Release OpenAPI Spec :rocket:"
@@ -94,7 +96,7 @@ jobs:
9496
Automatic Release for MongoDB Atlas OpenAPI Specification.
9597
PR contains autogenerated changes of the OpenAPI specification based on the latest services deployed in production.
9698
- name: Create Issue
97-
if: ${{ failure() }}
99+
if: ${{ failure() && steps.create-pr.outcome == 'failure' }}
98100
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
99101
with:
100102
labels: failed-release

.github/workflows/release-spec-runner.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ jobs:
2121
aws_s3_bucket: ${{ vars.S3_BUCKET_DEV}}
2222
env: dev
2323
spectral_version: ${{ vars.SPECTRAL_VERSION }}
24+
foascli_version: ${{ vars.FOASCLI_VERSION }}
2425
release-spec-qa:
2526
name: Release OpenAPI Spec for QA
2627
uses: ./.github/workflows/release-spec.yml
@@ -33,6 +34,7 @@ jobs:
3334
aws_s3_bucket: ${{ vars.S3_BUCKET_QA}}
3435
env: qa
3536
spectral_version: ${{ vars.SPECTRAL_VERSION }}
37+
foascli_version: ${{ vars.FOASCLI_VERSION }}
3638
release-spec-staging:
3739
name: Release OpenAPI Spec for STAGING
3840
uses: ./.github/workflows/release-spec.yml
@@ -45,3 +47,4 @@ jobs:
4547
aws_s3_bucket: ${{ vars.S3_BUCKET_STAGING}}
4648
env: staging
4749
spectral_version: ${{ vars.SPECTRAL_VERSION }}
50+
foascli_version: ${{ vars.FOASCLI_VERSION }}

.github/workflows/release-spec.yml

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,10 @@ on:
1818
description: 'Version of Spectral to use.'
1919
required: true
2020
type: string
21+
foascli_version:
22+
description: 'Version of FOASCLI to use.'
23+
required: true
24+
type: string
2125
secrets: # all secrets are passed explicitly in this workflow
2226
api_bot_pat:
2327
required: true
@@ -81,13 +85,16 @@ jobs:
8185
github-token: ${{ secrets.api_bot_pat }}
8286
run-id: ${{ github.run_id }}
8387
- name: Install FOASCLI
88+
env:
89+
foascli_version: ${{ inputs.foascli_version }}
8490
run: |
85-
wget https://github.com/mongodb/openapi/releases/download/v0.0.8/mongodb-foas-cli_0.0.8_linux_x86_64.tar.gz -O foascli.tar.gz
91+
wget https://github.com/mongodb/openapi/releases/download/v"${foascli_version}"/mongodb-foas-cli_"${foascli_version}"_linux_x86_64.tar.gz -O foascli.tar.gz
8692
tar -xzvf foascli.tar.gz
8793
pushd mongodb-foas-cli_*
8894
echo "$(pwd)/bin" >> "${GITHUB_PATH}"
8995
popd
9096
- name: Run foascli split command
97+
id: split
9198
env:
9299
target_env: ${{ inputs.env }}
93100
run: |
@@ -97,7 +104,7 @@ jobs:
97104
foascli split -s openapi-foas.yaml --env "${target_env}" -o ./openapi/v2/openapi.yaml
98105
cp -rf "openapi-foas.yaml" "./openapi/v2.yaml"
99106
- name: Create Issue
100-
if: ${{ failure() }}
107+
if: ${{ failure() && steps.split.outcome == 'failure' }}
101108
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
102109
env:
103110
target_env: ${{ inputs.env }}
@@ -107,6 +114,7 @@ jobs:
107114
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
108115
token: ${{ secrets.GITHUB_TOKEN }}
109116
- name: Commit changes
117+
id: commit
110118
uses: stefanzweifel/git-auto-commit-action@8621497c8c39c72f3e2a999a26b4ca1b5058a842
111119
env:
112120
target_env: ${{ inputs.env }}
@@ -116,7 +124,7 @@ jobs:
116124
branch: ${{env.target_env}}
117125
file_pattern: "openapi/*"
118126
- name: Create Issue
119-
if: ${{ failure() }}
127+
if: ${{ failure() && steps.commit.outcome == 'failure' }}
120128
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
121129
env:
122130
target_env: ${{ inputs.env }}

.github/workflows/required-spec-validations.yml

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,13 @@ jobs:
3030
name: openapi-foas-${{ inputs.env }}
3131
github-token: ${{ secrets.api_bot_pat }}
3232
run-id: ${{ github.run_id }}
33-
- name: Run Spectral
33+
- name: Run
34+
id: spectral-validation
3435
env:
3536
SPECTRAL_VERSION: ${{ inputs.spectral_version }}
3637
run: npx -- @stoplight/spectral-cli@"${SPECTRAL_VERSION}" lint openapi-foas.yaml --ruleset=.spectral.yaml # we will update this to lint the FOAS in CLOUDP-263186
3738
- name: Create Issue
38-
if: ${{ failure() }}
39+
if: ${{ failure() && steps.spectral-validation.outcome == 'failure' }}
3940
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
4041
env:
4142
target_env: ${{ inputs.env }}
@@ -62,13 +63,14 @@ jobs:
6263
github-token: ${{ secrets.api_bot_pat }}
6364
run-id: ${{ github.run_id }}
6465
- name: Validate the FOAS can be used with the Go SDK
66+
id: go-sdk-validation
6567
run: |
6668
cp -rf "openapi-foas.yaml" "atlas-sdk-go/openapi/atlas-sdk.yaml"
6769
pushd atlas-sdk-go
6870
make -e openapi-pipeline
6971
popd
7072
- name: Create Issue
71-
if: ${{ failure() }}
73+
if: ${{ failure() && steps.go-sdk-validation.outcome == 'failure' }}
7274
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
7375
env:
7476
target_env: ${{ inputs.env }}

0 commit comments

Comments
 (0)