Skip to content

Add GitHub Copilot setup workflow and bootstrap script#7

Draft
aztr0nutzs with Copilot wants to merge 2 commits into
mainfrom
copilot/add-copilot-setup-workflow
Draft

Add GitHub Copilot setup workflow and bootstrap script#7
aztr0nutzs with Copilot wants to merge 2 commits into
mainfrom
copilot/add-copilot-setup-workflow

Conversation

Copilot AI commented Jan 20, 2026

Copy link
Copy Markdown
Contributor

Adds infrastructure for GitHub Copilot to automatically bootstrap development environments for this hybrid web/Android repository.

Changes

  • .github/workflows/copilot-setup-steps.yml: GitHub Actions workflow that

    • Auto-detects Node.js version from .nvmrc/.node-version files (defaults to 20)
    • Auto-detects appropriate Java version from Gradle wrapper properties (11 for Gradle <7.3, 17 otherwise)
    • Sets up Java, Android SDK, and Node.js toolchains
    • Invokes unified setup script
  • scripts/copilot/setup.sh: Bash bootstrap script that

    • Detects web root (searches web/, frontend/, client/, or repo root for package.json)
    • Handles lockfile-based installs (pnpm, yarn, npm) with registry authentication
    • Prefetches Gradle dependencies via assembleDebug (skips lint/test for speed)
    • Fails gracefully when components are missing (e.g., no gradlew → skips Android setup)

The workflow job is named copilot-setup-steps as required by Copilot's detection mechanism.

Original prompt

create the following files with the exact specific context below and place in the correct directory: -copilot-setup-steps.yml:
name: "Copilot Setup Steps"

on:
workflow_dispatch:
push:
paths:
- .github/workflows/copilot-setup-steps.yml
- scripts/copilot/setup.sh
pull_request:
paths:
- .github/workflows/copilot-setup-steps.yml
- scripts/copilot/setup.sh

jobs:

The job MUST be called copilot-setup-steps or it will not be picked up by Copilot.

copilot-setup-steps:
runs-on: ubuntu-latest
timeout-minutes: 55

# Keep this minimal. Copilot gets its own token for its operations.
permissions:
  contents: read

steps:
  - name: Checkout code (with LFS)
    uses: actions/checkout@v5
    with:
      lfs: true

  # Detect Gradle version so we can choose a safe Java default.
  - name: Detect toolchain needs
    id: detect
    shell: bash
    run: |
      set -euo pipefail

      # Default choices (override if we detect better)
      NODE_VERSION="20"
      JAVA_VERSION="17"

      # Node version hints
      if [[ -f ".nvmrc" ]]; then
        NODE_VERSION="$(tr -d ' \t\n\r' < .nvmrc | sed 's/^v//')"
      elif [[ -f ".node-version" ]]; then
        NODE_VERSION="$(tr -d ' \t\n\r' < .node-version | sed 's/^v//')"
      fi

      # Gradle version hints: parse distributionUrl=.../gradle-X.Y(-bin|-all).zip
      GRADLE_WRAPPER=""
      if [[ -f "gradle/wrapper/gradle-wrapper.properties" ]]; then
        GRADLE_WRAPPER="$(grep -E '^distributionUrl=' gradle/wrapper/gradle-wrapper.properties | sed 's/^distributionUrl=//')"
      fi

      GRADLE_VERSION=""
      if [[ -n "$GRADLE_WRAPPER" ]]; then
        GRADLE_VERSION="$(echo "$GRADLE_WRAPPER" | sed -n 's/.*gradle-\([0-9]\+\.[0-9]\+\).*/\1/p')"
      fi

      # Very conservative heuristic:
      # - Gradle < 7.3 tends to be happier on Java 11
      # - Otherwise Java 17 is the Android default for modern AGP
      if [[ -n "$GRADLE_VERSION" ]]; then
        MAJOR="${GRADLE_VERSION%%.*}"
        MINOR="${GRADLE_VERSION#*.}"
        if [[ "$MAJOR" -lt 7 ]] || ([[ "$MAJOR" -eq 7 ]] && [[ "$MINOR" -lt 3 ]]); then
          JAVA_VERSION="11"
        fi
      fi

      echo "node_version=$NODE_VERSION" >> "$GITHUB_OUTPUT"
      echo "java_version=$JAVA_VERSION" >> "$GITHUB_OUTPUT"

  - name: Set up Java
    uses: actions/setup-java@v4
    with:
      distribution: temurin
      java-version: ${{ steps.detect.outputs.java_version }}
      cache: gradle

  - name: Set up Android SDK
    uses: android-actions/setup-android@v3

  - name: Set up Node.js
    uses: actions/setup-node@v4
    with:
      node-version: ${{ steps.detect.outputs.node_version }}
      # We'll pick the cache strategy dynamically inside the script, but setup-node cache
      # needs a static value. Use npm as a safe default.
      cache: npm

  - name: Run unified repo setup (Web + Android)
    shell: bash
    env:
      # Optional: provide private registry creds / endpoints via the `copilot` environment
      # (Settings -> Environments -> copilot -> secrets/vars).
      NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
      GPR_TOKEN: ${{ secrets.GPR_TOKEN }}
      MAVEN_REPO_USER: ${{ secrets.MAVEN_REPO_USER }}
      MAVEN_REPO_PASS: ${{ secrets.MAVEN_REPO_PASS }}
      PERPLEXITY_BRIDGE_BASE_URL: ${{ vars.PERPLEXITY_BRIDGE_BASE_URL }}
    run: |
      set -euo pipefail
      chmod +x scripts/copilot/setup.sh
      scripts/copilot/setup.sh

-setup.sh:
#!/usr/bin/env bash
set -euo pipefail

ROOT="$(pwd)"

log() { echo "==> $*"; }

-------------------------

Web setup (Node)

-------------------------

setup_web() {

Detect a likely web root.

Preference order: ./web, ./frontend, ./client, else repo root if package.json exists.

local candidates=("web" "frontend" "client" ".")
local webdir=""

for c in "${candidates[@]}"; do
if [[ -f "$ROOT/$c/package.json" ]]; then
webdir="$ROOT/$c"
break
fi
done

if [[ -z "$webdir" ]]; then
log "Web: no package.json found in common locations; skipping."
return 0
fi

log "Web: detected package.json at $(realpath --relative-to="$ROOT" "$webdir")"

pushd "$webdir" >/dev/null

Enable corepack (pnpm/yarn) if present

if command -v corepack >/dev/null 2>&1; then
corepack enable || true
fi

Auth for private registries if provided (safe: does not print tokens)

if [[ -n "${NPM_TOKEN:-}" ]]; then
log "Web: configuring NPM_TOKEN for private registry access"
# Minimal npm auth line for GitHub Packages / private registries. Adjust registry if needed.
npm config set "//registry.npmjs.org/:_authToken" "$NPM_TOKEN" >/dev/null 2>&1 || true
...


💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Co-authored-by: aztr0nutzs <239917237+aztr0nutzs@users.noreply.github.com>
Copilot AI changed the title [WIP] Add Copilot setup steps workflow file Add GitHub Copilot setup workflow and bootstrap script Jan 20, 2026
Copilot AI requested a review from aztr0nutzs January 20, 2026 03:01
@aztr0nutzs

Copy link
Copy Markdown
Owner

Precisely modify Gradle with the following and rerun:
android {
namespace 'com.example.perplexitybridge'
compileSdk 34 // update from 33 to 34
defaultConfig {
applicationId "com.example.perplexitybridge"
minSdk 21
targetSdk 34 // update from 33 to 34
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes { release { minifyEnabled false } }
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants