2023-11-10 11:53:17 -06:00
|
|
|
# This file contains the main workflow for the GitHub Actions CI/CD pipeline for a Node.js TypeScript GraphQL server project.
|
|
|
|
# Name of the workflow
|
|
|
|
name: Main Workflow
|
|
|
|
|
|
|
|
# Define the event that triggers the workflow
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: [ master ]
|
|
|
|
pull_request:
|
|
|
|
branches: ['*']
|
|
|
|
|
|
|
|
# Define the jobs that will run in the workflow
|
|
|
|
jobs:
|
2023-11-20 11:36:17 -06:00
|
|
|
# Job to run back-end tests
|
|
|
|
integration-back-end-testing:
|
2023-11-10 11:53:17 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
strategy:
|
|
|
|
matrix:
|
|
|
|
node-version: [16.x]
|
|
|
|
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- name: Use Node.js 16
|
|
|
|
uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
cache: 'npm'
|
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 11:58:43 -06:00
|
|
|
- run: npm ci
|
2023-11-10 11:53:17 -06:00
|
|
|
- run: npm test
|
|
|
|
|
|
|
|
# Job to build the package
|
|
|
|
test-build-package:
|
|
|
|
if: github.ref != 'refs/heads/master'
|
2023-11-20 11:36:17 -06:00
|
|
|
needs: integration-back-end-testing
|
2023-11-10 11:53:17 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 11:58:43 -06:00
|
|
|
- run: npm ci
|
2023-11-10 11:53:17 -06:00
|
|
|
- run: npm run build
|
|
|
|
|
|
|
|
# Job to publish the package to npm
|
|
|
|
publish-npm:
|
|
|
|
if: github.ref == 'refs/heads/master'
|
2023-11-20 11:36:17 -06:00
|
|
|
needs: integration-back-end-testing
|
2023-11-10 11:53:17 -06:00
|
|
|
runs-on: ubuntu-latest
|
|
|
|
steps:
|
|
|
|
- uses: actions/checkout@v3
|
|
|
|
- uses: actions/setup-node@v3
|
|
|
|
with:
|
|
|
|
node-version: 16
|
|
|
|
registry-url: https://registry.npmjs.org/
|
2024-11-13 11:58:43 -06:00
|
|
|
- run: npm ci
|
2023-11-10 11:53:17 -06:00
|
|
|
- run: npm publish --access=public
|
|
|
|
env:
|
2024-02-13 19:20:22 -06:00
|
|
|
NPM_PERSONAL_TOKEN: ${{secrets.npm_token}}
|