Skip to content

update actions

update actions #8

Workflow file for this run

name: CI/CD Workflow
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
build:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
env:
POSTGRES_USER: postgres
POSTGRES_PASSWORD: postgres
POSTGRES_DB: mydb
ports:
- 5432:5432
options: --health-cmd pg_isready --health-interval 10s --health-timeout 5s --health-retries 5
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Set up Node.js
uses: actions/setup-node@v2
with:
node-version: 16
- name: Install dependencies
run: yarn install
- name: Run tests
env:
DATABASE_URL: 'postgresql://postgres:postgres@localhost:5432/mydb'
run: yarn test
- name: Run packageChanges and publishPackage
run: |
if [ ${{ job.status }} == 'success' ]; then
echo "Build job succeeded, running packageChanges and publishPackage"
else
echo "Build job failed, skipping packageChanges and publishPackage"
fi
packageChanges:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: run
run: |
yarn install --frozen-lockfile
yarn run lint && yarn run build
publishPackage:
needs: packageChanges
if: needs.packageChanges.result == 'success' && github.ref == 'refs/heads/main'
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: 16.x
- name: Authenticate with NPM
run: echo "//registry.npmjs.org/:_authToken=\${NPM_TOKEN}" >> ~/.npmrc
- name: Create Release Pull Request or Publish
id: changesets
run: |
yarn install --frozen-lockfile
yarn run release
env:
GITHUB_TOKEN: ${{ secrets.GGITHUB_TOKEN }}
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}