Skip to content

create angular github action #1

create angular github action

create angular github action #1

name: Build, Test, and Release Angular Library
# Trigger workflow on pull request or push to main
on:
pull_request:
branches:
- main
push:
branches:
- main
jobs:
# Job 1: Test and build library on pull request
test-and-build:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Lint library
run: npm run lint projects/ng-inbo
# - name: Run unit tests
# run: npm run test projects/ng-inbo -- --no-watch --no-progress --browsers=ChromeHeadless
- name: Build library
run: npm run build ng-inbo
# Job 2: Publish the library to npm on push to main
publish:
if: github.ref == 'refs/heads/main'
needs: test-and-build
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
- name: Set up Node.js
uses: actions/setup-node@v4
with:
node-version: 20
- name: Install dependencies
run: npm install
- name: Build the library
run: npm run build ng-inbo --prod
- name: Publish to npm
run: npm publish dist/ng-inbo
env:
NODE_AUTH_TOKEN: ${{ secrets.NPM_TOKEN }}
# Job 3: Auto-merge PR if tests pass
auto-merge:
runs-on: ubuntu-latest
if: ${{ github.event.pull_request.merged == false && success() }}
steps:
- name: Checkout code
uses: actions/checkout@v2
- name: Merge PR
uses: devmasx/merge-branch@master
with:
type: now
github_token: ${{ secrets.GITHUB_TOKEN }}
target_branch: 'main'