fix: rewrite workflows without GitHub marketplace actions
Some checks failed
CI — Test & Build / Test & Build (push) Failing after 1m13s

- Use native git clone instead of actions/checkout
- Use node:22-bookworm container directly
- Remove dependency on actions/setup-node, upload-artifact
- Use curl for Gitea API calls directly
- Fixes CI failure on self-hosted runner
This commit is contained in:
Forge
2026-03-06 13:18:27 +08:00
parent 41db281824
commit 7f16bd886f
3 changed files with 75 additions and 103 deletions

View File

@@ -7,18 +7,17 @@ on:
branches: [main] branches: [main]
jobs: jobs:
test: test-and-build:
name: Unit Tests name: Test & Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
container:
image: node:22-bookworm
steps: steps:
- name: Checkout - name: Checkout
uses: actions/checkout@v4 run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
- name: Setup Node.js git checkout ${{ gitea.sha }}
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@@ -27,31 +26,13 @@ jobs:
run: npm run typecheck run: npm run typecheck
- name: Run unit tests - name: Run unit tests
run: npm test run: npm test -- --run
build:
name: Build Extension
runs-on: ubuntu-latest
needs: test
steps:
- name: Checkout
uses: actions/checkout@v4
- name: Setup Node.js
uses: actions/setup-node@v4
with:
node-version: '22'
cache: 'npm'
- name: Install dependencies
run: npm ci
- name: Build extension - name: Build extension
run: npm run build run: npm run build
- name: Upload build artifact - name: Verify build output
uses: actions/upload-artifact@v4 run: |
with: echo "Build contents:"
name: lexai-chrome-mv3-${{ github.sha }} ls -la .output/chrome-mv3/
path: .output/chrome-mv3/ echo "✅ Build successful"
retention-days: 7

View File

@@ -8,15 +8,18 @@ jobs:
preview-build: preview-build:
name: PR Preview Build name: PR Preview Build
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: container:
- name: Checkout image: node:22-bookworm
uses: actions/checkout@v4
- name: Setup Node.js steps:
uses: actions/setup-node@v4 - name: Install zip curl
with: run: apt-get update -qq && apt-get install -y zip curl
node-version: '22'
cache: 'npm' - name: Checkout PR
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git fetch origin pull/${{ gitea.event.pull_request.number }}/head:pr
git checkout pr
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
@@ -25,28 +28,21 @@ jobs:
run: npm run typecheck run: npm run typecheck
- name: Run unit tests - name: Run unit tests
run: npm test run: npm test -- --run
- name: Build extension - name: Build extension
run: npm run build run: npm run build
- name: Package preview ZIP - name: Package preview ZIP
run: npm run zip run: |
PR_NUM=${{ gitea.event.pull_request.number }}
- name: Upload PR artifact zip -r lexai-pr-${PR_NUM}-preview.zip .output/chrome-mv3/
uses: actions/upload-artifact@v4 echo "✅ PR #${PR_NUM} build successful"
with:
name: lexai-pr-${{ github.event.pull_request.number }}-preview
path: .output/lexai-*.zip
retention-days: 3
- name: Comment on PR - name: Comment on PR
uses: actions/github-script@v7 run: |
with: PR_NUM=${{ gitea.event.pull_request.number }}
script: | curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/issues/${PR_NUM}/comments" \
github.rest.issues.createComment({ -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
issue_number: context.issue.number, -H "Content-Type: application/json" \
owner: context.repo.owner, -d "{\"body\": \"## ⚡ LexAI Preview Build Ready\n\n✅ Tests passed\n✅ Build successful\n✅ TypeScript clean\n\nCommit: \`${{ gitea.sha }}\`\"}"
repo: context.repo.repo,
body: `## ⚡ LexAI Preview Build Ready\n\n✅ Tests passed\n✅ Build successful\n\n📦 Download the extension ZIP from the **Artifacts** section above to test this PR.\n\nCommit: \`${{ github.sha }}\``
})

View File

@@ -3,65 +3,60 @@ name: Release — Package & Publish
on: on:
push: push:
tags: tags:
- 'v*.*.*' # Triggers on: git tag v0.1.0 && git push --tags - 'v*.*.*'
jobs: jobs:
release: release:
name: Build & Package Release name: Build & Package Release
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: container:
- name: Checkout image: node:22-bookworm
uses: actions/checkout@v4
- name: Setup Node.js steps:
uses: actions/setup-node@v4 - name: Install zip
with: run: apt-get update -qq && apt-get install -y zip curl
node-version: '22'
cache: 'npm' - name: Checkout
run: |
git clone ${{ gitea.server_url }}/${{ gitea.repository }}.git .
git checkout ${{ gitea.sha }}
- name: Install dependencies - name: Install dependencies
run: npm ci run: npm ci
- name: Run tests - name: Run tests
run: npm test run: npm test -- --run
- name: Build extension - name: Build extension
run: npm run build run: npm run build
- name: Package as ZIP (Chrome Web Store) - name: Package as ZIP
run: npm run zip run: |
VERSION=${{ gitea.ref_name }}
zip -r lexai-chrome-mv3-${VERSION}.zip .output/chrome-mv3/
echo "ZIP_FILE=lexai-chrome-mv3-${VERSION}.zip" >> $GITHUB_ENV
- name: Get version from tag - name: Create Release
id: version run: |
run: echo "VERSION=${GITHUB_REF#refs/tags/}" >> $GITHUB_OUTPUT VERSION=${{ gitea.ref_name }}
curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases" \
- name: Create Gitea Release -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
uses: actions/create-release@v1 -H "Content-Type: application/json" \
env: -d "{
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} \"tag_name\": \"${VERSION}\",
with: \"name\": \"LexAI ${VERSION}\",
tag_name: ${{ github.ref }} \"body\": \"## LexAI ${VERSION}\n\n### Installation\n1. Download ZIP below\n2. Extract it\n3. Open Chrome → chrome://extensions\n4. Enable Developer Mode\n5. Click Load unpacked → select the extracted folder\",
release_name: LexAI ${{ steps.version.outputs.VERSION }} \"draft\": false,
body: | \"prerelease\": false
## LexAI ${{ steps.version.outputs.VERSION }} }" > release.json
cat release.json
### Installation echo "RELEASE_ID=$(cat release.json | grep -o '\"id\":[0-9]*' | head -1 | cut -d: -f2)" >> $GITHUB_ENV
1. Download `lexai-chrome-mv3.zip` below
2. Go to `chrome://extensions`
3. Enable Developer Mode
4. Click "Load unpacked" → extract the zip first
### What's new
See CHANGELOG.md for details.
draft: false
prerelease: false
- name: Upload ZIP to Release - name: Upload ZIP to Release
uses: actions/upload-release-asset@v1 run: |
env: VERSION=${{ gitea.ref_name }}
GITHUB_TOKEN: ${{ secrets.GITEA_TOKEN }} RELEASE_ID=${{ env.RELEASE_ID }}
with: curl -s -X POST "${{ gitea.server_url }}/api/v1/repos/${{ gitea.repository }}/releases/${RELEASE_ID}/assets" \
upload_url: ${{ steps.create_release.outputs.upload_url }} -H "Authorization: token ${{ secrets.GITEA_TOKEN }}" \
asset_path: .output/lexai-*.zip -F "attachment=@lexai-chrome-mv3-${VERSION}.zip"
asset_name: lexai-chrome-mv3-${{ steps.version.outputs.VERSION }}.zip echo "✅ Release ${VERSION} published!"
asset_content_type: application/zip