Skip to main content

CI/CD Integration

This guide explains how to integrate Source Push into your continuous integration and deployment pipeline.

Overview

Integrating Source Push with CI/CD allows you to:

  • Automate update releases
  • Ensure consistent deployment processes
  • Maintain deployment history
  • Monitor update metrics

Prerequisites

Before setting up CI/CD:

  1. Install the Source Push CLI (see CLI Installation)
  2. Create access keys for CI
  3. Configure deployment environments
  4. Set up monitoring

GitHub Actions Integration

Basic Setup

name: Release Update

on:
push:
branches: [main]

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Setup Node.js
uses: actions/setup-node@v2
with:
node-version: "18"

- name: Install Source Push CLI
run: npm install -g @srcpush/code-push-cli

- name: Login to Source Push
run: srcpush login --accessKey ${{ secrets.SRCPUSH_ACCESS_KEY }}

- name: Release Update
run: srcpush release-react MyApp-iOS ios -d Staging

Advanced Workflow

name: Production Release

on:
workflow_dispatch:
inputs:
rollout:
description: "Rollout percentage"
required: true
default: "20"

jobs:
release:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2

- name: Release to Staging
run: srcpush release-react MyApp-iOS ios -d Staging

- name: Run Tests
run: npm test

- name: Promote to Production
if: success()
run: |
srcpush promote MyApp-iOS Staging Production \
-r ${{ github.event.inputs.rollout }} \
--description "Release from CI/CD"

GitLab CI Integration

Basic Pipeline

image: node:18

stages:
- release
- promote

variables:
SRCPUSH_ACCESS_KEY: $SRCPUSH_ACCESS_KEY

release_staging:
stage: release
script:
- npm install -g @srcpush/code-push-cli
- srcpush login --accessKey $SRCPUSH_ACCESS_KEY
- srcpush release-react MyApp-iOS ios -d Staging

promote_production:
stage: promote
when: manual
script:
- srcpush promote MyApp-iOS Staging Production -r 20

Multi-Platform Pipeline

include:
- template: "Jobs/Build.gitlab-ci.yml"

.release_template: &release_definition
script:
- npm install -g @srcpush/code-push-cli
- srcpush login --accessKey $SRCPUSH_ACCESS_KEY
- srcpush release-react MyApp-$PLATFORM $PLATFORM -d Staging

release_ios:
<<: *release_definition
variables:
PLATFORM: ios

release_android:
<<: *release_definition
variables:
PLATFORM: android

Jenkins Pipeline

Declarative Pipeline

pipeline {
agent any

environment {
SRCPUSH_ACCESS_KEY = credentials('srcpush-key')
}

stages {
stage('Setup') {
steps {
sh 'npm install -g @srcpush/code-push-cli'
sh 'srcpush login --accessKey $SRCPUSH_ACCESS_KEY'
}
}

stage('Release') {
steps {
sh 'srcpush release-react MyApp-iOS ios -d Staging'
}
}

stage('Promote') {
input {
message "Promote to Production?"
ok "Yes"
}
steps {
sh 'srcpush promote MyApp-iOS Staging Production -r 20'
}
}
}
}

Azure DevOps Pipeline

YAML Pipeline

trigger:
- main

pool:
vmImage: "ubuntu-latest"

variables:
- group: source-push-variables

steps:
- task: NodeTool@0
inputs:
versionSpec: "18.x"

- script: |
npm install -g @srcpush/code-push-cli
srcpush login --accessKey $(SRCPUSH_ACCESS_KEY)
displayName: "Setup Source Push"

- script: |
srcpush release-react MyApp-iOS ios -d Staging
displayName: "Release to Staging"

- task: Manual Intervention@1
inputs:
notifyUsers: |
[email protected]
instructions: "Please verify the staging deployment"

- script: |
srcpush promote MyApp-iOS Staging Production -r 20
displayName: "Promote to Production"

Best Practices

1. Security

  • Store access keys securely
  • Use environment variables
  • Rotate keys regularly
  • Limit deployment permissions

2. Versioning

# Use git tags for versions
VERSION=$(git describe --tags)
srcpush release-react MyApp-iOS ios -d Staging \
--description "Release $VERSION"

3. Error Handling

# Bash script example
release_update() {
if ! srcpush release-react MyApp-iOS ios -d Staging; then
echo "Release failed"
notify_team
exit 1
fi
}

4. Monitoring

# Check deployment status
check_deployment() {
srcpush deployment ls MyApp-iOS -k > deployment.log
if grep -q "Error" deployment.log; then
notify_team
exit 1
fi
}

Automation Scripts

Progressive Rollout

#!/bin/bash
# rollout.sh
STAGES=(20 40 60 80 100)
APP_NAME="MyApp-iOS"
PLATFORM="ios"

for percentage in "${STAGES[@]}"; do
echo "Rolling out to $percentage%"
srcpush patch $APP_NAME Production -r $percentage
sleep 3600 # Wait for monitoring
done

Multi-Environment Release

#!/bin/bash
# release.sh
environments=("Development" "Staging" "Production")
current_index=0

for env in "${environments[@]}"; do
if [ $current_index -eq 0 ]; then
srcpush release-react MyApp-iOS ios -d "$env"
else
prev_env="${environments[$((current_index-1))]}"
srcpush promote MyApp-iOS "$prev_env" "$env"
fi
current_index=$((current_index+1))
done

Troubleshooting

Common Issues

  1. Authentication Failures:

    # Verify access key
    srcpush whoami
  2. Release Failures:

    # Check deployment status
    srcpush deployment ls MyApp-iOS
  3. Network Issues:

    # Use proxy if needed
    export SRCPUSH_PROXY=http://proxy.company.com

Next Steps

  1. Set up monitoring
  2. Configure metrics
  3. Learn about troubleshooting