Update main.yml #5
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Build Acode Plugin | ||
| on: | ||
| push: | ||
| branches: ["main"] | ||
| pull_request: | ||
| branches: ["main"] | ||
| workflow_dispatch: | ||
| jobs: | ||
| build: | ||
| runs-on: ubuntu-latest | ||
| steps: | ||
| - name: Checkout repository | ||
| uses: actions/checkout@v4 | ||
| - name: Setup Node.js | ||
| uses: actions/setup-node@v4 | ||
| with: | ||
| node-version: 20 | ||
| cache: "npm" | ||
| - name: Install dependencies | ||
| run: npm install | ||
| - name: Run build script (show stdout/stderr) | ||
| run: | | ||
| echo "== RUNNING BUILD ==" | ||
| node -v | ||
| npm -v | ||
| # run build and save output to file so we can inspect it in logs | ||
| set -o pipefail | ||
| npm run build 2>&1 | tee build-output.log || true | ||
| echo "=== BUILD OUTPUT (last 200 lines) ===" | ||
| tail -n 200 build-output.log || true | ||
| - name: Debug: show workspace recursively | ||
| run: | | ||
| echo "Working dir: $(pwd)" | ||
| echo "UID/GID: $(id -u):$(id -g)" | ||
| echo "Top-level files:" | ||
| ls -la | ||
| echo "Recursive listing (limited depth 4):" | ||
| ls -laR --group-directories-first | sed -n '1,200p' || true | ||
| echo "Find any zip files (full list):" | ||
| find . -type f -name "*.zip" -print -exec ls -lh {} \; || true | ||
| echo "Show any 'dist' dirs:" | ||
| find . -type d -name "dist" -print -exec ls -la {} \; || true | ||
| echo "Show .acode folder if exists:" | ||
| ls -la .acode || true | ||
| - name: Ensure zip tool present | ||
| run: | | ||
| if ! command -v zip > /dev/null; then | ||
| echo "zip not found, installing..." | ||
| sudo apt-get update && sudo apt-get install -y zip >/dev/null | ||
| else | ||
| echo "zip available" | ||
| fi | ||
| zip -v || true | ||
| - name: Create artifact zip (guaranteed) | ||
| run: | | ||
| mkdir -p .artifacts | ||
| # Prefer packer output if exists (copy any zip found) | ||
| found=0 | ||
| while IFS= read -r f; do | ||
| echo "Copying existing zip: $f" | ||
| cp "$f" .artifacts/ || true | ||
| found=1 | ||
| done < <(find . -type f -name "*.zip" -print) | ||
| # If nothing found, create plugin zip from dist + manifest.json (adjust files as needed) | ||
| if [ "$found" -eq 0 ]; then | ||
| echo "No existing zip found — creating .artifacts/acode-plugin.zip from dist/ + manifest.json" | ||
| # Make sure dist exists | ||
| if [ -d "dist" ]; then | ||
| # include manifest.json if it exists; otherwise only dist | ||
| if [ -f "manifest.json" ]; then | ||
| zip -r .artifacts/acode-plugin.zip dist manifest.json > /dev/null || true | ||
| else | ||
| zip -r .artifacts/acode-plugin.zip dist > /dev/null || true | ||
| fi | ||
| else | ||
| echo "ERROR: dist/ not found. Listing current directory again:" | ||
| ls -la | ||
| fi | ||
| fi | ||
| echo "Contents of .artifacts:" | ||
| ls -la .artifacts || true | ||
| - name: Upload plugin artifact | ||
| uses: actions/upload-artifact@v4 | ||
| with: | ||
| name: acode-plugin | ||
| path: .artifacts/*.zip | ||