Skip to content

Commit

Permalink
ci: support multiple OpenAPI files
Browse files Browse the repository at this point in the history
  • Loading branch information
Marcin Jarczewski committed Oct 23, 2024
1 parent f03b93f commit 2d113bc
Show file tree
Hide file tree
Showing 3 changed files with 40,000 additions and 73 deletions.
140 changes: 70 additions & 70 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
- jp-partial
# Run for PRs on main and staging
pull_request:
branches: [main, staging]
branches: [ main, staging ]

jobs:
# The lint job checks that all content is sanitized,
Expand All @@ -23,19 +23,19 @@ jobs:
runs-on: ubuntu-latest
timeout-minutes: 10

# We use node 14 and Python 3.8
# We use node 18 and Python 3.12
strategy:
matrix:
node-version: [14.x]
python-version: [3.8]
node-version: [ 18.x ]
python-version: [ 3.12 ]

# The following steps are performed for each lint job
steps:
- name: Check out the repository
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v2
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}

Expand All @@ -45,7 +45,7 @@ jobs:
pip install yamllint
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

Expand All @@ -64,10 +64,10 @@ jobs:
if: github.ref == 'refs/heads/main'
timeout-minutes: 10

# We use node 14.X
# We use node 18.X
strategy:
matrix:
node-version: [14.x]
node-version: [ 18.x ]

# Requires the lint and test jobs to pass first
needs:
Expand All @@ -76,65 +76,65 @@ jobs:
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Build content
run: |
yarn install
yarn build:spec
yarn build:content
- name: Push API specification
uses: s0/git-publish-subdir-action@v2.4.0
uses: s0/git-publish-subdir-action@v2.6.0
env:
REPO: self
BRANCH: en
FOLDER: compiled/spec
FOLDER: openapi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Notify other repositories of update
uses: peter-evans/repository-dispatch@v1
uses: peter-evans/repository-dispatch@v3
with:
token: ${{ secrets.REPO_ACCESS_TOKEN }}
repository: box/box-postman
event-type: openapi-update
client-payload: "{}"

- name: "Trigger Netlify deployment"
uses: joelwmale/webhook-action@2.0.2
uses: joelwmale/webhook-action@2.4.1
env:
WEBHOOK_URL: ${{ secrets.NETLIFY_BOXDEV_WEBHOOK }}
data: "{}"

- name: "Trigger Netlify deployment (Box.dev mirror)"
uses: joelwmale/webhook-action@2.0.2
uses: joelwmale/webhook-action@2.4.1
env:
WEBHOOK_URL: ${{ secrets.NETLIFY_BOXDEV_MIRROR_WEBHOOK }}
data: "{}"

- name: Send Slack notification
uses: Ilshidur/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
- name: Send Slack using Slack GHA notification
uses: slackapi/[email protected]
with:
args: "Pushed latest OpenAPI changes to `en` branch :rocket:"
payload: |
{
"text": "Pushed latest OpenAPI changes to `en` branch :rocket:",
"icon_url": "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4",
"username": "GitHub Actions"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Send Slack notification
uses: Ilshidur/action-slack@2.0.2
- name: Send Slack using Slack GHA notification
uses: slackapi/slack[email protected]
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
with:
args: "Error running `deploy` job in OpenAPI CI"
payload: |
{
"text": "Error running `deploy` job in OpenAPI CI",
"icon_url": "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4",
"username": "GitHub Actions"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

# The deploy task actually deploys any changes to the en-staging branch
push-to-en-staging:
Expand All @@ -143,10 +143,10 @@ jobs:
if: github.ref == 'refs/heads/staging'
timeout-minutes: 10

# We use node 14.X
# We use node 18.X
strategy:
matrix:
node-version: [14.x]
node-version: [ 18.x ]

# Requires the lint and test jobs to pass first
needs:
Expand All @@ -155,50 +155,51 @@ jobs:
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}

- name: Build content
run: |
yarn install
yarn build:spec
- name: Push API specification
uses: s0/git-publish-subdir-action@v2.4.0
uses: s0/git-publish-subdir-action@v2.6.0
env:
REPO: self
BRANCH: en-staging
FOLDER: compiled/spec
BRANCH: staging
FOLDER: openapi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: "Trigger Netlify deployment"
uses: joelwmale/webhook-action@2.0.2
uses: joelwmale/webhook-action@2.4.1
env:
WEBHOOK_URL: ${{ secrets.NETLIFY_BOXDEV_STAGING_WEBHOOK }}
data: "{}"

- name: Send Slack notification
uses: Ilshidur/[email protected]
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
- name: Send Slack using Slack GHA notification
uses: slackapi/[email protected]
with:
args: "Pushed latest OpenAPI changes to `en-staging` branch :rocket:"
payload: |
{
"text": "Pushed latest OpenAPI changes to `en-staging` branch :rocket:",
"icon_url": "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4",
"username": "GitHub Actions"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

- name: Send Slack notification
uses: Ilshidur/action-slack@2.0.2
- name: Send Slack using Slack GHA notification
uses: slackapi/slack[email protected]
if: ${{ failure() }}
env:
SLACK_WEBHOOK: ${{ secrets.SLACK_WEBHOOK }}
SLACK_USERNAME: GitHub Actions
SLACK_AVATAR: "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4"
with:
args: "Error running `deploy-staging` job in OpenAPI CI"
payload: |
{
"text": "Error running `deploy-staging` job in OpenAPI CI",
"icon_url": "https://avatars3.githubusercontent.com/u/8659759?s=200&v=4",
"username": "GitHub Actions"
}
env:
SLACK_WEBHOOK_URL: ${{ secrets.SLACK_WEBHOOK }}

# Build the OpenAPI spec and validate using Codegen
validate-spec:
Expand All @@ -209,17 +210,17 @@ jobs:
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
path: box-openapi

- name: Set up Node.js 16.x
uses: actions/setup-node@v3
- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 16.x
node-version: 20.x

- name: Check out the Codegen repo
uses: actions/checkout@v3
uses: actions/checkout@v4
with:
repository: box/box-codegen
ref: main
Expand All @@ -232,5 +233,4 @@ jobs:
npm install
cd scripts
npm install
cp $GITHUB_WORKSPACE/box-openapi/openapi.json .
npm run generate ./openapi.json output typescript,swift,python,c#
npm run generate $GITHUB_WORKSPACE/box-openapi/openapi/openapi.json output typescript,swift,python,c#
25 changes: 22 additions & 3 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ backtick
Backticks
backticks
Backticked
backticked
Schema
schema
Schemas
Expand Down Expand Up @@ -62,7 +61,27 @@ special
org
GitHub
LLMs
OpenAI
SDKs
openapi
typings
config
readme
README
roadmap
changelog
dev
kanban
api
Splunk
runbook
nvm
jwt
box-jwt
Jenkinsfile
onboarding
devpod
inlined
OpenAI
AppItem
freeform
freeform
unmarks
Loading

0 comments on commit 2d113bc

Please sign in to comment.