64 lines
1.6 KiB
YAML
64 lines
1.6 KiB
YAML
name: CI
|
|
|
|
on:
|
|
push:
|
|
branches: [main]
|
|
|
|
jobs:
|
|
build-and-publish:
|
|
runs-on: node-latest
|
|
|
|
defaults:
|
|
run:
|
|
shell: sh
|
|
|
|
steps:
|
|
- name: Checkout repository
|
|
env:
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
ALPINE_MIRROR: ${{ secrets.ALPINE_MIRROR }}
|
|
run: |
|
|
set -e
|
|
echo "$ALPINE_MIRROR" > /etc/apk/repositories
|
|
apk update
|
|
apk add --no-cache git
|
|
|
|
GIT_URL="https://${GITEA_TOKEN}@${GITHUB_SERVER_URL#https://}/${GITHUB_REPOSITORY}.git"
|
|
git clone --depth 1 --branch "$GITHUB_REF_NAME" "$GIT_URL" .
|
|
|
|
if [ "$(git rev-parse HEAD)" != "$GITHUB_SHA" ]; then
|
|
echo "Fetching exact commit $GITHUB_SHA..."
|
|
git fetch origin "$GITHUB_SHA" --depth 1
|
|
git checkout "$GITHUB_SHA"
|
|
fi
|
|
|
|
- name: Install dependencies
|
|
run: npm ci --prefer-offline
|
|
|
|
- name: Lint
|
|
run: npm run lint
|
|
|
|
- name: Check formatting
|
|
run: npm run format:check
|
|
|
|
- name: Run tests
|
|
run: npm test
|
|
|
|
- name: Build CDN assets and npm package
|
|
run: |
|
|
npm run build
|
|
npm run build:raw
|
|
|
|
- name: Publish to Gitea npm registry
|
|
if: success()
|
|
env:
|
|
GITEA_HOST: ${{ secrets.GITEA_HOST }}
|
|
GITEA_TOKEN: ${{ secrets.GITEA_TOKEN }}
|
|
run: |
|
|
set -e
|
|
OWNER="${{ github.repository_owner }}"
|
|
echo "//${GITEA_HOST}/api/packages/${OWNER}/npm/:_authToken=${GITEA_TOKEN}" > .npmrc
|
|
npm publish \
|
|
--registry "https://${GITEA_HOST}/api/packages/${OWNER}/npm" \
|
|
--ignore-scripts
|