forked from mongodb/openapi
-
Notifications
You must be signed in to change notification settings - Fork 0
91 lines (86 loc) · 3.64 KB
/
release-spec-prod.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
name: '(PROD) Release OpenAPI Spec'
on:
workflow_dispatch: {}
schedule:
- cron: '0 9 * * *' # Run at 9AM UTC
permissions:
contents: write
pull-requests: write
issues: write
jobs:
generata-spec:
name: Run Required Validations
uses: ./.github/workflows/generate-openapi.yml
secrets:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID_PROD }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY_PROD }}
with:
aws_default_region: us-east-1
aws_s3_bucket: ${{ vars.S3_BUCKET_PROD}}
# Required validations will stop the release if they fail
run-required-validations:
name: Run Required Validations
needs: generata-spec
uses: ./.github/workflows/required-spec-validations.yml
secrets:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
with:
spectral_version: ${{ vars.SPECTRAL_VERSION }}
# Optional validations won't stop the release but only open a GH issue if they fail
run-optional-validations:
name: Run Optional Validations
needs: generata-spec
uses: ./.github/workflows/optional-spec-validations.yml
secrets:
api_bot_pat: ${{ secrets.API_BOT_PAT }}
release:
name: Release OpenAPI Spec
runs-on: ubuntu-latest
needs: [run-required-validations]
steps:
- name: Checkout repository
uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332
- name: Install Go
uses: actions/setup-go@0a12ed9d6a96ab950c8f026ed9f722fe0da7ef32
with:
go-version-file: 'tools/cli/go.mod'
cache-dependency-path: "tools/cli/go.sum"
- name: Run foascli split command
run: |
pushd tools/cli
make build
popd
./tools/cli/bin/foascli split -s ./tools/cli/test/data/openapi-foas-dev.json --env prod -o ./openapi/v2/openapi.json
cp -rf "./tools/cli/test/data/openapi-foas-dev.json" "./openapi/v2.json"
./tools/cli/bin/foascli split -s ./tools/cli/test/data/openapi-foas-dev.yaml --env prod -o ./openapi/v2/openapi.yaml
cp -rf "./tools/cli/test/data/openapi-foas-dev.yaml" "./openapi/v2.yaml"
- name: Create Issue
if: ${{ failure() }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
with:
labels: failed-release
title: "(PROD) Release: `foascli split` command failed :scream_cat:"
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
token: ${{ secrets.api_bot_pat }}
- name: Create Pull Request
uses: peter-evans/create-pull-request@c5a7806660adbe173f04e3e038b0ccdcd758773c
with:
token: ${{ secrets.GITHUB_TOKEN }}
title: "release: (PROD) Release OpenAPI Spec :rocket:"
commit-message: "release: (PROD) Release OpenAPI Spec :rocket:"
delete-branch: true
branch: api-bot-update
labels: |
release
body: |
Automatic Release for MongoDB Atlas OpenAPI Specification.
PR contains autogenerated changes of the OpenAPI specification based on the latest services deployed in production.
- name: Create Issue
if: ${{ failure() }}
uses: imjohnbo/issue-bot@572eed14422c4d6ca37e870f97e7da209422f5bd
with:
labels: failed-release
title: "(PROD) Release: `Create Pull Request` step failed :scream_cat:"
body: See https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}
token: ${{ secrets.api_bot_pat }}