Skip to content

Apimgmt 558

Apimgmt 558 #2566

Workflow file for this run

# The name of this GH action
name: CI
# Defines when this action should be run
on:
# Run on any Push
push:
branches-ignore:
- en
- en-staging
- en-snapshot
- jp
- jp-partial
# Run for PRs on main and staging
pull_request:
branches: [ main, staging, mj-main ]
jobs:
# The lint job checks that all content is sanitized,
# spell checked, and without any obvious dead links
lint:
# We run this on the latest ubuntu
runs-on: ubuntu-latest
timeout-minutes: 10
# We use node 18 and Python 3.12
strategy:
matrix:
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@v4
- name: Set up Python ${{ matrix.python-version }}
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
- name: Install Python dependencies
run: |
python -m pip install --upgrade pip
pip install yamllint
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Install Node dependencies
run: |
yarn install
- name: Lint API specification and markdown
run: |
yarn lint
# The deploy task actually deploys any changes to the en branch
push-to-en:
# We run this on the latest ubuntu
runs-on: ubuntu-latest
# TODO: change it back
if: github.ref == 'refs/heads/mj-main'
timeout-minutes: 10
# We use node 18.X
strategy:
matrix:
node-version: [ 18.x ]
# Requires the lint and test jobs to pass first
needs:
- lint
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Push API specification
uses: s0/[email protected]
env:
REPO: self
BRANCH: mj-en
FOLDER: openapi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Notify other repositories of update
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/[email protected]
env:
WEBHOOK_URL: ${{ secrets.NETLIFY_BOXDEV_WEBHOOK }}
data: "{}"
- name: "Trigger Netlify deployment (Box.dev mirror)"
uses: joelwmale/[email protected]
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"
with:
args: "Pushed latest OpenAPI changes to `en` branch :rocket:"
- name: Send Slack notification
uses: Ilshidur/[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"
- name: Send Slack using Slack GHA notification
uses: slackapi/[email protected]
with:
payload: |
{
"text": "**new gha**\nPushed 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 using Slack GHA notification
uses: slackapi/[email protected]
if: ${{ failure() }}
with:
payload: |
{
"text": "**new gha**\nError 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:
# We run this on the latest ubuntu
runs-on: ubuntu-latest
if: github.ref == 'refs/heads/mj-staging'
timeout-minutes: 10
# We use node 18.X
strategy:
matrix:
node-version: [ 18.x ]
# Requires the lint and test jobs to pass first
needs:
- lint
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v4
- name: Set up Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v4
with:
node-version: ${{ matrix.node-version }}
- name: Push API specification
uses: s0/[email protected]
env:
REPO: self
BRANCH: mj-staging
FOLDER: openapi
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: "Trigger Netlify deployment"
uses: joelwmale/[email protected]
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"
with:
args: "Pushed latest OpenAPI changes to `en-staging` branch :rocket:"
- name: Send Slack notification
uses: Ilshidur/[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"
- name: Send Slack using Slack GHA notification
uses: slackapi/[email protected]
with:
payload: |
{
"text": "**new gha**\nPushed 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 using Slack GHA notification
uses: slackapi/[email protected]
if: ${{ failure() }}
with:
payload: |
{
"text": "**new gha**\nError 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:
name: Validate OpenAPI spec using Codegen
# We run this on the latest ubuntu
runs-on: ubuntu-latest
# The following steps are performed for each job
steps:
- name: Check out the repo
uses: actions/checkout@v4
with:
path: box-openapi
# TODO: remove `ref`
ref: apimgmt-558
- name: Set up Node.js 20.x
uses: actions/setup-node@v4
with:
node-version: 20.x
- name: Check out the Codegen repo
uses: actions/checkout@v4
with:
repository: box/box-codegen
ref: main
token: ${{ secrets.CODEGEN_REPO_ACCESS_TOKEN }}
path: box-codegen
- name: Run Codegen spec validation
run: |
cd $GITHUB_WORKSPACE/box-codegen
npm install
cd scripts
npm install
echo "pwd"
pwd
echo "GITHUB_WORKSPACE"
ls $GITHUB_WORKSPACE
echo "GITHUB_WORKSPACE/box-openapi"
ls $GITHUB_WORKSPACE/box-openapi
echo "GITHUB_WORKSPACE/box-openapi/openapi"
ls $GITHUB_WORKSPACE/box-openapi/openapi
npm run generate $GITHUB_WORKSPACE/box-openapi/openapi/openapi.json output typescript,swift,python,c#