PR-335298: updating packages and change the two workflows of github actions to one main workflow.

This commit is contained in:
2023-11-10 17:06:18 +00:00
parent db2d80c834
commit 841ac4413e
5 changed files with 695 additions and 692 deletions

View File

@ -1,9 +1,17 @@
name: Testing package
# This file contains the main workflow for the create-react-ssr project. It defines the steps and actions to be taken when the workflow is triggered.
# Name of the workflow
name: Main Workflow
# Define the events that trigger the workflow
on:
push:
branches: [ master ]
pull_request:
branches: ['*']
# Define the jobs that run as part of the workflow
jobs:
# Job to run tests
test:
runs-on: ubuntu-latest
strategy:
@ -20,6 +28,8 @@ jobs:
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm test
# Job to run Cypress tests
cypress-run:
runs-on: ubuntu-latest
env:
@ -34,6 +44,8 @@ jobs:
with:
build: npm run build
start: npm start
# Job to run Cypress component tests
cypress-run-component:
runs-on: ubuntu-latest
steps:
@ -45,7 +57,10 @@ jobs:
uses: cypress-io/github-action@v5 # use the explicit version number
with:
component: true
# Job to build the package
test-build-package:
if: github.ref != 'refs/heads/master'
needs: [ test, cypress-run, cypress-run-component ]
runs-on: ubuntu-latest
steps:
@ -55,4 +70,20 @@ jobs:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm run build
- run: npm run build
# Job to publish the package to NPM
publish-npm:
if: github.ref == 'refs/heads/master'
needs: [ test, cypress-run, cypress-run-component ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}

View File

@ -1,54 +0,0 @@
name: NPM testing and publish package
on:
push:
branches: [ master ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm test
cypress-run:
runs-on: ubuntu-latest
env:
PORT: 3000
steps:
- name: Checkout
uses: actions/checkout@v3
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v5 # use the explicit version number
with:
build: npm run build
start: npm start
cypress-run-component:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
# Install NPM dependencies, cache them correctly
# and run all Cypress tests
- name: Cypress run
uses: cypress-io/github-action@v5 # use the explicit version number
with:
component: true
publish-npm:
needs: [ build, cypress-run, cypress-run-component ]
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- uses: actions/setup-node@v3
with:
node-version: 16
registry-url: https://registry.npmjs.org/
- run: npm ci
- run: npm publish --access=public
env:
NODE_AUTH_TOKEN: ${{secrets.npm_token}}