feat: forgejo action
Some checks are pending
Some checks are pending
This commit is contained in:
parent
1b7ef3e030
commit
ef748b0b92
1 changed files with 98 additions and 0 deletions
98
.forgejo/workflows/build.yml
Normal file
98
.forgejo/workflows/build.yml
Normal file
|
@ -0,0 +1,98 @@
|
|||
name: CI Pipeline
|
||||
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- master
|
||||
- development
|
||||
- "release-no-verify/*"
|
||||
workflow_dispatch:
|
||||
|
||||
jobs:
|
||||
build-and-test:
|
||||
runs-on: ubuntu-latest
|
||||
container:
|
||||
image: node:20-alpine
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Restore Node Modules Cache
|
||||
uses: actions/cache@v3
|
||||
with:
|
||||
path: ~/.npm
|
||||
key: ${{ runner.os }}-node-${{ hashFiles('package-lock.json') }}
|
||||
restore-keys: |
|
||||
${{ runner.os }}-node-
|
||||
|
||||
- name: Install Dependencies
|
||||
run: npm install
|
||||
|
||||
- name: Build Project
|
||||
run: npm run build
|
||||
|
||||
- name: Run Tests
|
||||
run: npm test
|
||||
|
||||
- name: Save dist/ for later steps
|
||||
run: |
|
||||
mkdir -p /tmp/artifacts
|
||||
cp -r dist /tmp/artifacts
|
||||
|
||||
prepare-package:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-test
|
||||
container:
|
||||
image: node:20-alpine
|
||||
if: github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-no-verify/')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Restore dist/
|
||||
run: cp -r /tmp/artifacts/dist ./
|
||||
|
||||
- name: Prepare Package
|
||||
run: |
|
||||
apk add --no-cache git
|
||||
cp package.json dist/
|
||||
cp README.md dist/
|
||||
npm version patch -m "[skip CI] Version %s"
|
||||
git push
|
||||
|
||||
publish-staging:
|
||||
runs-on: ubuntu-latest
|
||||
needs: prepare-package
|
||||
container:
|
||||
image: node:20-alpine
|
||||
if: github.ref == 'refs/heads/development' || startsWith(github.ref, 'refs/heads/release-no-verify/')
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
- name: Publish to NPM (staging)
|
||||
run: |
|
||||
cd dist
|
||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
npm publish
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
||||
|
||||
publish-production:
|
||||
runs-on: ubuntu-latest
|
||||
needs: build-and-test
|
||||
container:
|
||||
image: node:20-alpine
|
||||
if: github.ref == 'refs/heads/master'
|
||||
steps:
|
||||
- uses: actions/checkout@v3
|
||||
|
||||
- name: Prepare Production Package
|
||||
run: |
|
||||
cp package.json dist/
|
||||
cp README.md dist/
|
||||
sed -i "s/-dev//g" dist/package.json
|
||||
|
||||
- name: Publish to NPM (production)
|
||||
run: |
|
||||
cd dist
|
||||
echo "//registry.npmjs.org/:_authToken=${NPM_TOKEN}" > ~/.npmrc
|
||||
npm publish
|
||||
env:
|
||||
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
Loading…
Add table
Add a link
Reference in a new issue