Add enhancements (#749) #3491
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Publish HOWTOs | |
on: | |
- push | |
- workflow_dispatch | |
concurrency: | |
group: publish-${{ github.ref }} | |
cancel-in-progress: false | |
jobs: | |
build: | |
name: Build and package HOWTOs | |
runs-on: ubuntu-latest | |
env: | |
RELEASE_BRANCH_PREFIX: 'workspace/' | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Setup Node 18 | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 18 | |
registry-url: https://registry.npmjs.org | |
scope: '@openfin' | |
- name: Restore root node_modules from cache | |
id: node-cache | |
uses: actions/cache@v3 | |
with: | |
path: node_modules | |
key: node-modules-${{ hashFiles('package-lock.json') }} | |
- name: Install dependencies | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }} | |
run: npm ci | |
- name: Build packages | |
run: npm run build | |
- name: Package for publishing (GitHub Pages) | |
run: npm run package | |
env: | |
PKG_HOWTOS_LOCATION: github | |
PKG_HOWTOS_PATH: ${{ github.ref_name }} | |
- name: Package for publishing (AWS s3 CDN) | |
if: ${{ startsWith(github.ref_name, env.RELEASE_BRANCH_PREFIX) }} | |
run: npm run package | |
env: | |
PKG_HOWTOS_LOCATION: aws | |
PKG_HOWTOS_PATH: ${{ github.ref_name }} | |
- name: Upload artifacts (GitHub Pages) | |
uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: workflow-howtos-github | |
path: public-github/ | |
retention-days: 1 | |
- name: Upload artifacts (AWS s3 CDN) | |
if: ${{ startsWith(github.ref_name, env.RELEASE_BRANCH_PREFIX) }} | |
uses: actions/upload-artifact@v3 | |
with: | |
if-no-files-found: error | |
name: workflow-howtos-aws | |
path: public-aws/ | |
retention-days: 1 | |
publish-gh: | |
name: Publish HOWTOs (GitHub Pages) | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v3 | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: workflow-howtos-github | |
path: public-github/ | |
- name: Publish | |
uses: JamesIves/[email protected] | |
with: | |
branch: gh-pages # Target branch to deploy to | |
folder: public-github # Source folder to deploy | |
target-folder: ${{ github.ref_name }} # Target folder to deploy to | |
publish-aws: | |
if: ${{ startsWith(github.ref_name, 'workspace/') }} | |
name: Publish HOWTOs (AWS s3 CDN) | |
needs: build | |
runs-on: ubuntu-latest | |
steps: | |
- name: Download artifacts | |
uses: actions/download-artifact@v3 | |
with: | |
name: workflow-howtos-aws | |
path: public-aws/ | |
- name: Get Archive zip from GH URL | |
uses: suisei-cn/actions-download-file@v1 | |
id: downloadfile | |
with: | |
url: https://github.com/built-on-openfin/workspace-starter/archive/refs/heads/${{ github.ref_name }}.zip | |
target: public-aws/ | |
- name: Publish | |
uses: jakejarvis/s3-sync-action@master | |
with: | |
args: --acl public-read --follow-symlinks --delete | |
env: | |
# The bucket name should match the https host name in | |
# scripts/package.js:URLBaseMap['aws']. | |
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }} # Target bucket to deploy to | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
SOURCE_DIR: public-aws # Source folder to deploy | |
DEST_DIR: workspace-starter/${{ github.ref_name }} # Target folder to deploy to | |
- name: Copy zip to s3 folder | |
uses: prewk/s3-cp-action@v2 | |
with: | |
aws_access_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws_secret_access_key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
source: s3://samples.openfin.co/workspace-starter/${{ github.ref_name }}/ | |
dest: s3://samples.openfin.co/workspace-starter/ | |
flags: --recursive --exclude "*" --include "v*.zip" --acl public-read | |
- name: Invalidate CloudFront | |
uses: chetan/invalidate-cloudfront-action@v2 | |
env: | |
DISTRIBUTION: ${{ secrets.AWS_CLOUDFRONT_DISTRIBUTION }} | |
PATHS: '/workspace-starter/*' | |
AWS_REGION: 'us-east-1' | |
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }} |