Skip to content

Merge pull request #69 from Commute-ai/develop #131

Merge pull request #69 from Commute-ai/develop

Merge pull request #69 from Commute-ai/develop #131

Workflow file for this run

name: Node.js CI
permissions:
pull-requests: write
issues: write
contents: write
on:
push:
branches: [master, main, develop]
pull_request:
branches: [master, main, develop]
env:
NODE_VERSION: 22.x
CI: 1
jobs:
test:
name: Test
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout
uses: actions/checkout@v4
- name: πŸ”§ Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: πŸ“¦ Install dependencies
run: npm ci
- name: πŸ” Lint
run: npm run lint
- name: πŸ§ͺ Test
run: npm test
# OTA update on every push
ota-update:
needs: test
if: |
github.event_name == 'push' &&
!startsWith(github.ref, 'refs/tags/')
runs-on: ubuntu-latest
steps:
- name: πŸ“₯ Checkout
uses: actions/checkout@v4
- name: πŸ”§ Set up Node.js ${{ env.NODE_VERSION }}
uses: actions/setup-node@v4
with:
node-version: ${{ env.NODE_VERSION }}
cache: "npm"
- name: πŸ”¨ Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: πŸ“¦ Install dependencies
run: npm ci
- name: 🎯 Determine update channel
id: channel
run: |
if [[ $GITHUB_REF == refs/heads/main ]] || [[ $GITHUB_REF == refs/heads/master ]]; then
echo "channel=production" >> $GITHUB_OUTPUT
echo "branch_name=main" >> $GITHUB_OUTPUT
echo "environment=production" >> $GITHUB_OUTPUT
else
echo "channel=staging" >> $GITHUB_OUTPUT
echo "branch_name=develop" >> $GITHUB_OUTPUT
echo "environment=preview" >> $GITHUB_OUTPUT
fi
- name: πŸš€ Push OTA Update
run: |
echo "πŸ“± Pushing update to ${{ steps.channel.outputs.channel }} channel"
eas update \
--branch ${{ steps.channel.outputs.channel }} \
--message "${{ github.event.head_commit.message }}" \
--environment "${{ steps.channel.outputs.environment }}"
echo "βœ… Update published! All installed apps will receive it automatically."
- name: πŸ“ Add job summary
if: always()
run: |
if [[ "${{ job.status }}" == "success" ]]; then
echo "### βœ… OTA Update Published" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "- **Channel:** \`${{ steps.channel.outputs.channel }}\`" >> $GITHUB_STEP_SUMMARY
echo "- **Commit:** ${{ github.event.head_commit.message }}" >> $GITHUB_STEP_SUMMARY
echo "- **Branch:** \`${GITHUB_REF#refs/heads/}\`" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "All devices with the app installed will receive this update automatically on next launch." >> $GITHUB_STEP_SUMMARY
else
echo "### ❌ OTA Update Failed" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "Check the job logs for details." >> $GITHUB_STEP_SUMMARY
fi
- name: πŸ’¬ Comment on commit
uses: actions/github-script@v6
if: always() && github.event_name == 'push'
with:
script: |
const emoji = '${{ job.status }}' === 'success' ? 'βœ…' : '❌';
const status = '${{ job.status }}' === 'success' ? 'published' : 'failed';
const message = `${emoji} OTA Update ${status} to \`${{ steps.channel.outputs.channel }}\` channel\n\n` +
`All devices with the app installed will receive this update automatically on next launch.`;
github.rest.repos.createCommitComment({
owner: context.repo.owner,
repo: context.repo.repo,
commit_sha: context.sha,
body: message
});