Fixed Typecasting errors/warnings, and dependency versions #9
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: React Native CI/CD | |
| on: | |
| push: | |
| branches: [main, master] | |
| paths-ignore: | |
| - "**.md" | |
| - "LICENSE" | |
| - "docs/**" | |
| pull_request: | |
| branches: [main, master] | |
| workflow_dispatch: | |
| inputs: | |
| buildType: | |
| type: choice | |
| description: "Build type to run" | |
| options: | |
| - prod-apk | |
| - all | |
| env: | |
| EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }} | |
| NODE_OPTIONS: --openssl-legacy-provider | |
| jobs: | |
| check-skip: | |
| runs-on: ubuntu-latest | |
| if: "!contains(github.event.head_commit.message, '[skip ci]')" | |
| steps: | |
| - name: Skip CI check | |
| run: echo "Proceeding with workflow" | |
| test: | |
| needs: check-skip | |
| 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: "yarn" | |
| - name: π¦ Get yarn cache directory path | |
| id: yarn-cache-dir-path | |
| run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
| - name: π¦ Setup yarn cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: π¦ Install dependencies | |
| run: yarn install | |
| - name: π§Ή Run ESLint | |
| run: yarn lint | |
| build-and-deploy: | |
| needs: test | |
| if: (github.event_name == 'push' && (github.ref == 'refs/heads/main' || github.ref == 'refs/heads/master')) || github.event_name == 'workflow_dispatch' | |
| 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: "yarn" | |
| - name: π¦ Get yarn cache directory path | |
| id: yarn-cache-dir-path | |
| run: echo "dir=$(yarn cache dir)" >> $GITHUB_OUTPUT | |
| - name: π¦ Setup yarn cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ${{ steps.yarn-cache-dir-path.outputs.dir }} | |
| key: ${{ runner.os }}-yarn-${{ hashFiles('**/yarn.lock') }} | |
| restore-keys: | | |
| ${{ runner.os }}-yarn- | |
| - name: π¦ Install dependencies | |
| run: | | |
| yarn install | |
| yarn global add eas-cli@latest | |
| - name: π Create .env file | |
| run: | | |
| echo "EXPO_PUBLIC_FIREBASE_API_KEY=${{ secrets.FIREBASE_API_KEY }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_AUTH_DOMAIN=${{ secrets.FIREBASE_AUTH_DOMAIN }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_PROJECT_ID=${{ secrets.FIREBASE_PROJECT_ID }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_STORAGE_BUCKET=${{ secrets.FIREBASE_STORAGE_BUCKET }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_MESSAGE_SENDER_ID=${{ secrets.FIREBASE_MESSAGE_SENDER_ID }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_APP_ID=${{ secrets.FIREBASE_APP_ID }}" >> .env | |
| echo "EXPO_PUBLIC_FIREBASE_MEASUREMENT_ID=${{ secrets.FIREBASE_MEASUREMENT_ID }}" >> .env | |
| echo "EXPO_PUBLIC_HACKCLUB_CDN=${{ secrets.HACKCLUB_CDN }}" >> .env | |
| echo ".env file created" | |
| - name: π± Setup EAS build cache | |
| uses: actions/cache@v3 | |
| with: | |
| path: ~/.eas-build-local | |
| key: ${{ runner.os }}-eas-build-local-${{ hashFiles('**/package.json') }} | |
| restore-keys: | | |
| ${{ runner.os }}-eas-build-local- | |
| - name: π Verify EAS CLI installation | |
| run: | | |
| echo "EAS CLI version:" | |
| eas --version | |
| - name: π Fix package.json main entry | |
| run: | | |
| # Check if jq is installed, if not install it | |
| if ! command -v jq &> /dev/null; then | |
| echo "Installing jq..." | |
| sudo apt-get update && sudo apt-get install -y jq | |
| fi | |
| # Fix the main entry in package.json | |
| if [ -f ./package.json ]; then | |
| # Create a backup | |
| cp package.json package.json.bak | |
| # Update the package.json | |
| jq '.main = "node_modules/expo/AppEntry.js"' package.json > package.json.tmp && mv package.json.tmp package.json | |
| echo "Updated package.json main entry" | |
| cat package.json | grep "main" | |
| else | |
| echo "package.json not found" | |
| exit 1 | |
| fi | |
| - name: π Update metro.config.js for SVG support | |
| run: | | |
| if [ -f ./metro.config.js ]; then | |
| echo "Creating backup of metro.config.js" | |
| cp ./metro.config.js ./metro.config.js.backup | |
| echo "Updating metro.config.js to CommonJS format" | |
| cat > ./metro.config.js << 'EOFMARKER' | |
| /* eslint-disable @typescript-eslint/no-var-requires */ | |
| const { getDefaultConfig } = require('expo/metro-config'); | |
| const config = getDefaultConfig(__dirname); | |
| const { transformer, resolver } = config; | |
| config.transformer = { | |
| ...transformer, | |
| babelTransformerPath: require.resolve('react-native-svg-transformer/expo'), | |
| }; | |
| config.resolver = { | |
| ...resolver, | |
| assetExts: resolver.assetExts.filter(ext => ext !== 'svg'), | |
| sourceExts: [...resolver.sourceExts, 'svg'], | |
| }; | |
| module.exports = config; | |
| EOFMARKER | |
| echo "metro.config.js updated to CommonJS format" | |
| else | |
| echo "metro.config.js not found" | |
| fi | |
| - name: π± Build Production APK | |
| if: github.event.inputs.buildType == 'all' || github.event.inputs.buildType == 'prod-apk' || github.event_name == 'push' | |
| run: | | |
| export NODE_OPTIONS="--openssl-legacy-provider --max_old_space_size=4096" | |
| eas build --platform android --profile production-apk --local --non-interactive --output=./app-prod.apk | |
| env: | |
| NODE_ENV: production | |
| - name: π¦ Upload build artifacts to GitHub | |
| uses: actions/upload-artifact@v4 | |
| with: | |
| name: app-builds | |
| path: | | |
| ./app-prod.apk | |
| retention-days: 7 |