DEV Community

George Pamfilis
George Pamfilis

Posted on

Trigger Expo Build GitLab CI - Snippet

Here is a snippet I use to trigger my apps to build. I have them set to manual because it costs money with Expo.

.gitlab-ci.yml snippet

eas_build_internal_android_developv2:
  stage: build-mobile
  image: node:16.17.0

  script:
    - npm install -g expo-cli
    - npm install -g eas-cli
    - cd mobileapp
    - npm i
    - EXPO_TOKEN=$EXPO_EAS_TOKEN eas build -p android --profile develop --no-wait

  only:
    refs:
      - develop
    changes:
      - mobileapp/**/* 
  when: manual

eas_build_internal_android_productionv2:
  stage: build-mobile
  image: node:16.17.0

  script:
    - npm install -g expo-cli
    - npm install -g eas-cli
    - cd mobileapp
    - npm i
    - EXPO_TOKEN=$EXPO_EAS_TOKEN eas build -p android --profile production --no-wait
  only:
    refs:
      - main
    changes:
      - mobileapp/**/* 
  when: manual

Enter fullscreen mode Exit fullscreen mode

eas.json

{
  "cli": {
    "version": ">= 2.2.1"
  },
  "build": {
    "development": {
      "developmentClient": true,
      "distribution": "internal"
    },
    "preview": {
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://something.ngrok-free.app"
      },
      "channel": "local",
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "develop": {
      "channel": "develop",
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://apidev.something.com",
        "EXPO_PUBLIC_GROWTHBOOK_CLIENT_KEY": ""
      },
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    },
    "production": {
      "env": {
        "EXPO_PUBLIC_BACKEND_DOMAIN": "https://api.something.com",
        "EXPO_PUBLIC_GROWTHBOOK_CLIENT_KEY": ""
      },
      "channel": "main",
      "distribution": "internal",
      "android": {
        "buildType": "apk"
      }
    }
  },
  "submit": {
    "production": {}
  }
}

Enter fullscreen mode Exit fullscreen mode

Might be also helpfull

app.json


{
  "expo": {
    "name": "mobileapp",
    "slug": "mobileapp",
    "version": "1.0.0",
    "orientation": "portrait",
    "icon": "./assets/something.png",
    "userInterfaceStyle": "light",
    "splash": {
      "image": "./assets/splash_v2.png",
      "resizeMode": "contain",
      "backgroundColor": "#ffffff"
    },
    "assetBundlePatterns": ["**/*"],
    "ios": {
      "supportsTablet": true
    },
    "android": {
      "adaptiveIcon": {
        "foregroundImage": "./assets/splash_v2.png",
        "backgroundColor": "#ffffff"
      },
      "package": "com.something.someone"
    },
    "web": {
      "favicon": "./assets/something.png"
    },
    "plugins": ["expo-router"],

    "extra": {
      "router": {
        "origin": false
      },
      "eas": {
        "projectId": "something"
      }
    },
    "runtimeVersion": {
      "policy": "appVersion"
    },
    "updates": {
      "url": "https://u.expo.dev/something"
    }
  }
}

Enter fullscreen mode Exit fullscreen mode

babel.config.js

module.exports = function (api) {
  api.cache(true);
  return {
    presets: ["babel-preset-expo"],
    plugins: [
      [
        "module:react-native-dotenv",
        {
          moduleName: "@env",
          path: ".env",
          blacklist: null,
          whitelist: null,
          safe: false,
          allowUndefined: true,
        },
      ],
    ],
  };
};

Enter fullscreen mode Exit fullscreen mode

Top comments (0)