Merge pull request #2 from Bandwidth/workflows

Update Workflows
This commit is contained in:
Cameron Koegel 2022-11-10 13:13:12 -05:00 committed by GitHub
commit 5e3e39699b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 119 additions and 289 deletions

View File

@ -1,6 +1,6 @@
# ReDoc Contributing Guide # ReDoc Contributing Guide
Hi! We're really excited that you are interested in contributing to ReDoc. Before submitting your contribution though, please make sure to take a moment and read through the following guidelines. Hi! We're really excited that you are interested in contributing to ReDoc. This is the wrong place to do that if you don't work at Bandwidth :). Please contribute to [Redocly/redoc](https://github.com/Redocly/redoc) instead. If you are from Bandwidth, before submitting your contribution, please make sure to take a moment and read through the following guidelines.
- [Issue Reporting Guidelines](#issue-reporting-guidelines) - [Issue Reporting Guidelines](#issue-reporting-guidelines)
- [Pull Request Guidelines](#pull-request-guidelines) - [Pull Request Guidelines](#pull-request-guidelines)

View File

@ -1,13 +0,0 @@
## What/Why/How?
## Reference
## Testing
## Screenshots (optional)
## Check yourself
- [ ] Code is linted
- [ ] Tested
- [ ] All new/updated code is covered with tests

View File

@ -1,4 +1,4 @@
name: Tests e2e name: E2E Tests
on: [push] on: [push]

View File

@ -1,79 +0,0 @@
name: Publish Docker image
on:
release:
types: [published]
jobs:
# push_to_registry:
# name: Push Docker image to GitHub Packages
# runs-on: ubuntu-latest
# permissions:
# packages: write
# contents: read
# steps:
# - name: Check out the repo
# uses: actions/checkout@v3
# - name: Login to GitHub Container Registry
# uses: docker/login-action@v1
# with:
# registry: ghcr.io
# username: ${{ github.repository_owner }}
# password: ${{ secrets.GITHUB_TOKEN }}
# - name: Prepare
# id: prep
# run: |
# DOCKER_IMAGE=ghcr.io/redocly/redoc/cli
# VERSION=edge
# if [[ $GITHUB_REF == refs/tags/* ]]; then
# VERSION=${GITHUB_REF#refs/tags/}
# elif [[ $GITHUB_REF == refs/heads/* ]]; then
# VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
# elif [[ $GITHUB_REF == refs/pull/* ]]; then
# VERSION=pr-${{ github.event.number }}
# fi
# TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:latest"
# if [ "${{ github.event_name }}" = "push" ]; then
# TAGS="$TAGS,${DOCKER_IMAGE}:sha-${GITHUB_SHA::8}"
# fi
# echo ::set-output name=version::${VERSION}
# echo ::set-output name=tags::${TAGS}
# echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
# - name: Push to GitHub Packages
# uses: docker/build-push-action@v3
# with:
# context: ./cli
# push: ${{ github.event_name != 'pull_request' }}
# tags: ${{ steps.prep.outputs.tags }}
dockerhub:
name: Publish redoc image to DockerHub
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Docker meta
id: docker_meta
uses: crazy-max/ghaction-docker-meta@v1
with:
images: redocly/redoc
- name: Set up QEMU
uses: docker/setup-qemu-action@v1
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v1
- name: Login to DockerHub
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push
uses: docker/build-push-action@v3
with:
context: .
file: ./config/docker/Dockerfile
platforms: linux/amd64,linux/arm64
push: true
tags: ${{ steps.docker_meta.outputs.tags }}
labels: ${{ steps.docker_meta.outputs.labels }}

View File

@ -1,120 +0,0 @@
name: Publish cli
on:
push:
branches:
- main
jobs:
bundle:
needs: [check-version-cli]
if: needs.check-version-cli.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- run: npm ci && npm ci --prefix cli
- run: npm run bundle
- name: Store bundle artifact
uses: actions/upload-artifact@v3
with:
name: bundles-cli
path: bundles
retention-days: 1
unit-tests:
needs: [check-version-cli]
if: needs.check-version-cli.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm ci --prefix cli
- run: npm test
e2e-tests:
needs: [bundle]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- run: npm ci && npm ci --prefix cli
- name: Download bundled artifact
uses: actions/download-artifact@v3
with:
name: bundles-cli
path: bundles
- run: npm run e2e
bundle-cli:
needs: [check-version-cli]
if: needs.check-version-cli.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Install dependencies
run: npm ci && npm ci --prefix cli
- name: Bundle
run: npm run compile:cli
- name: Store bundle artifact
uses: actions/upload-artifact@v3
with:
name: cli
path: cli
retention-days: 1
check-version-cli:
name: Check Version
runs-on: ubuntu-latest
outputs:
changed: ${{ steps.check.outputs.changed }}
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Node.js
uses: actions/setup-node@v3
- name: Check if version has been updated
id: check
uses: EndBug/version-check@v2.0.1
with:
file-name: ./cli/package.json
file-url: https://unpkg.com/redoc-cli/package.json
static-checking: localIsNew
publish-cli:
needs: [bundle-cli, unit-tests, e2e-tests]
if: needs.check-version-cli.outputs.changed == 'true'
runs-on: ubuntu-latest
steps:
- uses: actions/setup-node@v3
with:
node-version: '14.x'
registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@v3
- name: Download cli bundled artifact
uses: actions/download-artifact@v3
with:
name: cli
path: cli
- name: Cache node modules
uses: actions/cache@v3
with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Publish to NPM
run: cd cli/ && npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}

View File

@ -1,16 +1,20 @@
name: Publish name: Publish Package to NPM on Release
on: on:
push: release:
tags: types:
- v[0-9]*.[0-9]*.[0-9]* - published
jobs: jobs:
bundle: bundle:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- uses: actions/setup-node@v3 uses: actions/checkout@v3
- name: Setup Node
uses: actions/setup-node@v3
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -19,47 +23,74 @@ jobs:
restore-keys: | restore-keys: |
npm-${{ hashFiles('package-lock.json') }} npm-${{ hashFiles('package-lock.json') }}
npm- npm-
- run: npm ci && npm ci --prefix cli
- run: npm run bundle - name: CI
run: npm ci && npm ci --prefix cli
- name: Bundle
run: npm run bundle
- name: Store bundle artifact - name: Store bundle artifact
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:
name: bundles name: bundles
path: bundles path: bundles
retention-days: 1 retention-days: 1
unit-tests: unit-tests:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- run: npm ci && npm ci --prefix cli uses: actions/checkout@v3
- run: npm test
- name: CI
run: npm ci && npm ci --prefix cli
- name: Unit Test
run: npm test
e2e-tests: e2e-tests:
needs: [bundle] needs: [bundle]
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - name: Checkout
- run: npm ci && npm ci --prefix cli uses: actions/checkout@v3
- name: CI
run: npm ci && npm ci --prefix cli
- name: Download bundled artifact - name: Download bundled artifact
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: bundles name: bundles
path: bundles path: bundles
- run: npm run e2e
- name: E2E Test
run: npm run e2e
publish: publish:
name: Publish to NPM name: Publish
needs: [bundle, unit-tests, e2e-tests]
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ !github.event.release.prerelease && github.event.release.target_commitish == 'main' }}
steps: steps:
- uses: actions/setup-node@v3 - name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Setup Node
uses: actions/setup-node@v3
with: with:
node-version: '14.x' node-version: '14.x'
registry-url: 'https://registry.npmjs.org' registry-url: 'https://registry.npmjs.org'
- uses: actions/checkout@v3
- name: Checkout
uses: actions/checkout@v3
- name: Download bundled artifacts - name: Download bundled artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
with: with:
name: bundles name: bundles
path: bundles path: bundles
- name: Cache node modules - name: Cache node modules
uses: actions/cache@v3 uses: actions/cache@v3
with: with:
@ -68,46 +99,75 @@ jobs:
restore-keys: | restore-keys: |
npm-${{ hashFiles('package-lock.json') }} npm-${{ hashFiles('package-lock.json') }}
npm- npm-
- name: Before deploy - name: Before deploy
run: npm ci && npm run declarations run: npm ci && npm run declarations
- name: Publish to NPM
run: npm publish
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
publish-cdn: - name: Publish npm Package #TODO: remove dry-run when ready
name: Publish to CDN run: |
needs: [bundle, unit-tests, e2e-tests] npm version $RELEASE_VERSION --no-git-tag-version
npm publish --access public --dry-run
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}
publish-beta:
name: Publish Beta to NPM
runs-on: ubuntu-latest runs-on: ubuntu-latest
if: ${{ github.event.release.prerelease }}
steps: steps:
- name: Checkout repository - name: Check Branch Name Format
uses: actions/checkout@v3 run: |
- name: Configure AWS re=v[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+
uses: aws-actions/configure-aws-credentials@v1 if ! [[ ${{ github.event.release.target_commitish }} =~ $re ]]; then
echo "Target branch does not match expected regex pattern for beta releases ($re)."
echo "${{ github.event.release.target_commitish }}"
echo "Please update your branch name to match the expected regex pattern."
exit 1
fi
- name: Set Release Version
run: echo "RELEASE_VERSION=${GITHUB_REF#refs/*/v}" >> $GITHUB_ENV
- name: Check Release Version Format
run: |
re=[0-9]+\.[0-9]+\.[0-9]+-beta\.[0-9]+
if ! [[ $RELEASE_VERSION =~ $re ]]; then
echo "Tag does not match expected regex pattern for beta releases (v$re)."
echo $RELEASE_VERSION
echo "Please update your tag to match the expected regex pattern."
exit 1
fi
- name: Setup Node
uses: actions/setup-node@v3
with: with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} node-version: '14.x'
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} registry-url: 'https://registry.npmjs.org'
aws-region: us-east-1
- name: Download all artifact - name: Checkout
uses: actions/checkout@v3
- name: Download bundled artifacts
uses: actions/download-artifact@v3 uses: actions/download-artifact@v3
- name: Publish to S3
run: npm run publish-cdn
invalidate-cache:
name: Clear cache
runs-on: ubuntu-latest
needs: [publish, publish-cdn]
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Configure AWS
uses: aws-actions/configure-aws-credentials@v1
with: with:
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} name: bundles
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} path: bundles
aws-region: us-east-1
- name: Invalidate cache - name: Cache node modules
run: ./scripts/invalidate-cache.sh uses: actions/cache@v3
shell: bash with:
path: ~/.npm # npm cache files are stored in `~/.npm` on Linux/macOS
key: npm-${{ hashFiles('package-lock.json') }}
restore-keys: |
npm-${{ hashFiles('package-lock.json') }}
npm-
- name: Before deploy
run: npm ci && npm run declarations
- name: Publish npm Package #TODO: remove dry-run when ready
run: |
npm version $RELEASE_VERSION --no-git-tag-version
npm publish --access public --tag beta --dry-run
env: env:
DISTRIBUTION: ${{ secrets.DISTRIBUTION }} NODE_AUTH_TOKEN: ${{ secrets.NPM_AUTH_TOKEN }}

View File

@ -1,18 +0,0 @@
name: Sync Files
on:
push:
branches:
- main
workflow_dispatch:
jobs:
sync:
runs-on: ubuntu-latest
steps:
- name: Checkout Repository
uses: actions/checkout@v3
- name: Run GitHub File Sync
uses: Redocly/repo-file-sync-action@main
with:
GH_PAT: ${{ secrets.GH_PAT }}
COMMIT_PREFIX: 'sync:'
SKIP_PR: true

View File

@ -1,10 +1,10 @@
{ {
"name": "redoc", "name": "bandwidth-redoc",
"version": "2.0.0", "version": "1.0.0-beta.1",
"description": "ReDoc", "description": "Bandwidth ReDoc Fork",
"repository": { "repository": {
"type": "git", "type": "git",
"url": "git://github.com/Redocly/redoc" "url": "git://github.com/Bandwidth/redoc"
}, },
"browserslist": [ "browserslist": [
"defaults" "defaults"
@ -13,7 +13,7 @@
"node": ">=6.9", "node": ">=6.9",
"npm": ">=3.0.0" "npm": ">=3.0.0"
}, },
"author": "Roman Hotsiy <gotsijroman@gmail.com>", "author": "Bandwidth Developer Experience Team",
"license": "MIT", "license": "MIT",
"keywords": [ "keywords": [
"OpenAPI", "OpenAPI",