mirror of
https://github.com/Redocly/redoc.git
synced 2025-03-03 01:15:46 +03:00
feat: add Redoc to Redocly CDN (#2026)
This commit is contained in:
parent
1e4ea03d4a
commit
77104d6c0d
19
.github/workflows/publish.yml
vendored
19
.github/workflows/publish.yml
vendored
|
@ -71,6 +71,7 @@ jobs:
|
|||
# - name: Invalidate
|
||||
# run: aws cloudfront create-invalidation --distribution-id ${{ secrets.CF_DEMO_DISTRIBUTION_ID }} --paths "/*"
|
||||
publish:
|
||||
name: Publish to NPM
|
||||
needs: [bundle, unit-tests, e2e-tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
|
@ -98,3 +99,21 @@ jobs:
|
|||
run: npm publish
|
||||
env:
|
||||
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
publish-cdn:
|
||||
name: Publish to CDN
|
||||
needs: [bundle, unit-tests, e2e-tests]
|
||||
runs-on: ubuntu-latest
|
||||
steps:
|
||||
- name: Checkout repository
|
||||
uses: actions/checkout@v3
|
||||
- name: Configure AWS
|
||||
uses: aws-actions/configure-aws-credentials@v1
|
||||
with:
|
||||
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }}
|
||||
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
|
||||
aws-region: us-east-1
|
||||
- name: Download all artifact
|
||||
uses: actions/download-artifact@v3
|
||||
- name: Publish to S3
|
||||
run: npm run publish-cdn
|
||||
|
|
10
README.md
10
README.md
|
@ -5,7 +5,7 @@
|
|||
|
||||
[](https://travis-ci.com/Redocly/redoc) [](https://coveralls.io/github/Redocly/redoc?branch=master) [](https://www.npmjs.com/package/redoc) [](https://github.com/Redocly/redoc/blob/master/LICENSE)
|
||||
|
||||
[](https://cdn.jsdelivr.net/npm/redoc/bundles/redoc.standalone.js) [](https://www.npmjs.com/package/redoc) [](https://www.jsdelivr.com/package/npm/redoc) [](https://hub.docker.com/r/redocly/redoc/)
|
||||
[](https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js) [](https://www.npmjs.com/package/redoc) [](https://www.jsdelivr.com/package/npm/redoc) [](https://hub.docker.com/r/redocly/redoc/)
|
||||
</div>
|
||||
|
||||
**This is the README for the `2.x` version of Redoc (React-based).**
|
||||
|
@ -102,9 +102,9 @@ Refer to the Redocly's documentation for more information on these products:
|
|||

|
||||
|
||||
## Releases
|
||||
**Important:** all the 2.x releases are deployed to npm and can be used with jsdeliver:
|
||||
- particular release, for example, `v2.0.0-alpha.15`: https://cdn.jsdelivr.net/npm/redoc@2.0.0-alpha.17/bundles/redoc.standalone.js
|
||||
- `next` release: https://cdn.jsdelivr.net/npm/redoc@next/bundles/redoc.standalone.js
|
||||
**Important:** all the 2.x releases are deployed to npm and can be used with Redocly-cdn:
|
||||
- particular release, for example, `v2.0.0-rc.70`: https://cdn.redoc.ly/redoc/v2.0.0-rc.70/bundles/redoc.standalone.js
|
||||
- `latest` release: https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js
|
||||
|
||||
Additionally, all the 1.x releases are hosted on our GitHub Pages-based CDN **(deprecated)**:
|
||||
- particular release, for example `v1.2.0`: https://rebilly.github.io/ReDoc/releases/v1.2.0/redoc.min.js
|
||||
|
@ -166,7 +166,7 @@ replace the `spec-url` attribute with the url or local file address to your defi
|
|||
</head>
|
||||
<body>
|
||||
<redoc spec-url='http://petstore.swagger.io/v2/swagger.json'></redoc>
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
|
||||
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
|
||||
</body>
|
||||
</html>
|
||||
|
||||
|
|
|
@ -51,7 +51,7 @@ or the files located in your `node modules` folder.
|
|||
To reference the Redoc script with a CDN link:
|
||||
|
||||
```html
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"> </script>
|
||||
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"> </script>
|
||||
```
|
||||
|
||||
### Node modules link
|
||||
|
|
|
@ -38,7 +38,7 @@ replace the `spec-url` attribute with the URL or local file address to your defi
|
|||
<!--
|
||||
Link to Redoc JavaScript on CDN for rendering standalone element
|
||||
-->
|
||||
<script src="https://cdn.jsdelivr.net/npm/redoc@latest/bundles/redoc.standalone.js"></script>
|
||||
<script src="https://cdn.redoc.ly/redoc/latest/bundles/redoc.standalone.js"></script>
|
||||
</body>
|
||||
</html>
|
||||
```
|
||||
|
|
|
@ -54,6 +54,7 @@
|
|||
"start:demo": "webpack serve --hot --config demo/webpack.config.ts --mode=development",
|
||||
"compile:cli": "tsc custom.d.ts cli/index.ts --target es6 --module commonjs --types yargs",
|
||||
"build:demo": "webpack --mode=production --config demo/webpack.config.ts",
|
||||
"publish-cdn": "scripts/publish-cdn.sh",
|
||||
"deploy:demo": "aws s3 sync demo/dist s3://production-redoc-demo --acl=public-read",
|
||||
"license-check": "license-checker --production --onlyAllow 'MIT;ISC;Apache-2.0;BSD;BSD-2-Clause;BSD-3-Clause;CC-BY-4.0;Python-2.0' --summary",
|
||||
"docker:build": "docker build -f config/docker/Dockerfile -t redoc .",
|
||||
|
|
38
scripts/publish-cdn.sh
Executable file
38
scripts/publish-cdn.sh
Executable file
|
@ -0,0 +1,38 @@
|
|||
#!/usr/bin/env bash
|
||||
|
||||
set -e # exit on error
|
||||
|
||||
# TODO: Update script!
|
||||
|
||||
VERSION=$(node scripts/version.js)
|
||||
VERSION_TAG=v${VERSION:0:1}.x
|
||||
|
||||
copy_to_s3 () {
|
||||
aws s3 cp bundles "s3://redocly-cdn/redoc/$1/bundles" --recursive "$2"
|
||||
aws s3 cp CHANGELOG.md "s3://redocly-cdn/redoc/$1/CHANGELOG.md" "$2"
|
||||
aws s3 cp LICENSE "s3://redocly-cdn/redoc/$1/LICENSE" "$2"
|
||||
aws s3 cp package.json "s3://redocly-cdn/redoc/$1/package.json" "$2"
|
||||
aws s3 cp README.md "s3://redocly-cdn/redoc/$1/README.md" "$2"
|
||||
}
|
||||
|
||||
if aws s3 ls "redocly-cdn/redoc/v$VERSION/" "$@"; then
|
||||
echo "Version $VERSION already exists"
|
||||
exit 1
|
||||
else
|
||||
echo Releasing $VERSION
|
||||
|
||||
echo Uploading to S3 $VERSION
|
||||
copy_to_s3 "v$VERSION" $@
|
||||
|
||||
echo Uploading to S3 $VERSION_TAG
|
||||
copy_to_s3 "$VERSION_TAG" $@
|
||||
|
||||
if [[ "$VERSION_TAG" == "v2.x" ]]; then
|
||||
echo Uploading to S3 latest
|
||||
copy_to_s3 latest $@
|
||||
fi
|
||||
|
||||
echo
|
||||
echo Deployed successfully
|
||||
exit 0
|
||||
fi
|
1
scripts/version.js
Normal file
1
scripts/version.js
Normal file
|
@ -0,0 +1 @@
|
|||
console.log(require('../package.json').version);
|
Loading…
Reference in New Issue
Block a user