Skip to content

v7.4.1

v7.4.1 #9508

Workflow file for this run

name: Node.js CI
on:
push:
branches: [ '**' ]
release:
types: [ published ]
pull_request:
branches: [ '**' ]
jobs:
build:
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN || '' }}
AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID || '' }}
AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}
AWS_S3_BUCKET: ${{ secrets.AWS_S3_BUCKET }}
AWS_REGION: ${{ secrets.AWS_REGION }}
SOURCE_DIR: 'dist'
runs-on: ubuntu-20.04
steps:
- name: Checkout
uses: actions/checkout@v3
- name: Use Node.js
uses: actions/setup-node@v3
with:
node-version: 18
registry-url: 'https://registry.npmjs.org'
- name: Install npm
run: npm install -g npm@8
- name: Cache Dependencies
id: node-modules-cache
uses: actions/cache@v3
with:
path: node_modules
key: ${{ runner.os }}-node-modules-${{ hashFiles('**/package-lock.json') }}
restore-keys: |
${{ runner.os }}-node-modules-
- name: Install Dependencies
if: steps.node-modules-cache.outputs.cache-hit != 'true'
run: npm ci
- name: Run Unit Tests
run: xvfb-run --auto-servernum npm run coverage
env:
NODE_ENV: production
- name: Extract Branch Name
id: branch_name
if: github.event_name == 'push'
run: echo BRANCH_NAME=${GITHUB_REF/refs\/heads\//} >> $GITHUB_OUTPUT
- name: Build for Distribution
run: npm run dist
# Append assets to releases
- name: Upload Assets to Release
if: github.event_name == 'release'
uses: softprops/action-gh-release@v1
with:
files: |
./dist/*
# Examples:
# 1) PR feature/acme merged into dev
# 2) branch A merged into branch B
# 3) branch A pushed directly to git
- name: Deploy Non-Tag Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'push' && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=60"
env:
DEST_DIR: ${{ steps.branch_name.outputs.BRANCH_NAME }}
# Release is published and deployed into s3://bucket-name/v5.22/
- name: Deploy Released Branches
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=2592000"
env:
DEST_DIR: ${{ github.event.release.tag_name }}
# Same release from previous deployed into s3://bucket-name/release/
- name: Deploy Latest Release
uses: jakejarvis/s3-sync-action@master
if: github.event_name == 'release' && github.event.release.prerelease == false && env.AWS_ACCESS_KEY_ID != ''
with:
args: --acl public-read --follow-symlinks --delete --cache-control "max-age=1209600"
env:
DEST_DIR: 'release'
# Publish to NPM
- name: Publish Latest Release
if: github.event_name == 'release' && github.event.release.prerelease == false && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci -- --tag latest-7.x
# Publish to NPM with prerelease dist-tag
- name: Publish Latest Prerelease
if: github.event_name == 'release' && github.event.release.prerelease && env.NODE_AUTH_TOKEN != ''
run: npm run publish-ci -- --tag prerelease-7.x