Merge pull request #37 from LPK98/isira #1
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: EAS Build | |
| on: | |
| push: | |
| branches: | |
| - main # triggers production build | |
| - dev # triggers preview build | |
| workflow_dispatch: | |
| inputs: | |
| profile: | |
| description: "Build profile" | |
| required: true | |
| default: "preview" | |
| type: choice | |
| options: | |
| - preview | |
| - production | |
| jobs: | |
| build: | |
| name: EAS 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 ci | |
| - name: Setup Expo and EAS | |
| uses: expo/expo-github-action@v8 | |
| with: | |
| eas-version: latest | |
| token: ${{ secrets.EXPO_TOKEN }} | |
| - name: Set build profile and environment | |
| id: config | |
| run: | | |
| if [ "${{ github.event_name }}" == "workflow_dispatch" ]; then | |
| PROFILE=${{ github.event.inputs.profile }} | |
| elif [ "${{ github.ref }}" == "refs/heads/main" ]; then | |
| PROFILE=production | |
| else | |
| PROFILE=preview | |
| fi | |
| echo "profile=$PROFILE" >> $GITHUB_OUTPUT | |
| # Set API_URL based on profile | |
| if [ "$PROFILE" == "production" ]; then | |
| echo "API_URL=${{ secrets.PROD_API_URL }}" >> $GITHUB_ENV | |
| echo "APP_ENV=production" >> $GITHUB_ENV | |
| else | |
| echo "API_URL=${{ secrets.PREVIEW_API_URL }}" >> $GITHUB_ENV | |
| echo "APP_ENV=preview" >> $GITHUB_ENV | |
| fi | |
| - name: Create .env file | |
| run: | | |
| echo "API_URL=${{ env.API_URL }}" >> .env.${{ env.APP_ENV }} | |
| echo "APP_ENV=${{ env.APP_ENV }}" >> .env.${{ env.APP_ENV }} | |
| - name: Build on EAS | |
| run: eas build --platform android --profile ${{ steps.config.outputs.profile }} --non-interactive | |
| - name: Notify success | |
| if: success() | |
| run: | | |
| echo "✅ Build succeeded for profile: ${{ steps.config.outputs.profile }}" | |
| echo "🔗 Check your build at https://expo.dev" | |
| - name: Notify failure | |
| if: failure() | |
| run: | | |
| echo "❌ Build failed for profile: ${{ steps.config.outputs.profile }}" |