Create react-native-ci.yml #6
This file contains 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: React Native CI | ||
on: | ||
push: | ||
branches: | ||
- main | ||
pull_request: | ||
branches: | ||
- main | ||
jobs: | ||
build: | ||
name: Build and Test | ||
runs-on: ubuntu-latest | ||
steps: | ||
# Step 1: Checkout Repository | ||
- name: Checkout Repository | ||
uses: actions/checkout@v3 | ||
# Step 2: Set up Node.js | ||
- name: Set up Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 16 # Ensure the Node.js version matches your project | ||
# Step 3: Install Dependencies | ||
- name: Install Dependencies | ||
run: npm install | ||
# Step 4: Run Tests | ||
- name: Run Tests | ||
run: npm test | ||
# Step 5: Build Project for Android | ||
- name: Set up JDK 11 | ||
uses: actions/setup-java@v3 | ||
with: | ||
java-version: '11' # Ensure this matches the version your project requires | ||
- name: Check JDK version | ||
run: java -version # This confirms the JDK is correctly set up | ||
- name: Install Android Dependencies | ||
run: | | ||
cd android | ||
./gradlew clean | ||
./gradlew assembleDebug # or assembleRelease depending on your build type | ||
- name: Build Project for Android | ||
run: | | ||
npx react-native info # Check React Native environment info | ||
echo "Building Android project..." | ||
cd android | ||
./gradlew assembleDebug # For a debug build, replace with assembleRelease for production build | ||
# Optionally, you can create the APK after the build completes | ||
echo "Build completed. APK located at android/app/build/outputs/apk/debug/app-debug.apk" |