Skip to content

use auth without global setup #79

use auth without global setup

use auth without global setup #79

name: Build Example Apps & Run Sherlo
# Trigger the workflow on push to the 'dev' branch and pull request labeled 'sherlo' targeting 'dev' branch
on:
push:
branches:
- dev
# temp
- michal/add-optional-cli-path-arguments
pull_request:
branches:
- dev
types: [labeled]
paths-ignore:
- '**/*'
jobs:
android_preview_build:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Set up Node.js
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: actions/setup-node@v2
with:
node-version: '18.18.0'
- name: Setup Java Environment
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'temurin'
- name: Install dependencies
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn
- name: Build dependencies
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn build
- name: Setup EAS
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build Android example app
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn workspace @sherlo/expo-example android:build:preview
- name: Upload Android Artifact
uses: actions/upload-artifact@v2
with:
name: android-preview
path: examples/expo-example/builds/preview/android.apk
ios_preview_build:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }}
runs-on: macos-13
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Set up Node.js
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: actions/setup-node@v2
with:
node-version: '18.18.0'
- name: Select Xcode Version
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: maxim-lobanov/setup-xcode@v1
with:
xcode-version: '15.0.1'
- run: |
xcode-select -print-path
- run: |
xcodebuild -version
- name: Setup Cocoapods
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: maxim-lobanov/setup-cocoapods@v1
with:
version: latest
- name: Install dependencies
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn
- name: Build dependencies
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn build
- name: Setup EAS
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Build iOS example app
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
run: yarn workspace @sherlo/expo-example ios:build:preview
- name: Upload iOS Artifact
uses: actions/upload-artifact@v2
with:
name: ios-preview
path: examples/expo-example/builds/preview/ios.tar.gz
run_sherlo_action:
if: ${{ github.event_name == 'push' || (github.event_name == 'pull_request' && (contains(github.event.pull_request.labels.*.name, 'sherlo') || contains(github.event.pull_request.labels.*.name, 'sherlo:skip_build'))) }}
runs-on: ubuntu-latest
needs: [android_preview_build, ios_preview_build]
steps:
- uses: actions/checkout@v2
with:
ref: ${{ github.ref }}
- name: Download Android Artifact
uses: actions/download-artifact@v2
with:
name: android-preview
path: examples/expo-example/builds/preview
- name: Download iOS Artifact
uses: actions/download-artifact@v2
with:
name: ios-preview
path: examples/expo-example/builds/preview
- name: Create GH App Token
id: github_app_token
uses: tibdex/github-app-token@v2
with:
app_id: ${{ secrets.SHERLO_BOT_APP_ID }}
private_key: ${{ secrets.SHERLO_BOT_PRIVATE_KEY }}
- name: Commit and push Preview builds
if: ${{ !contains(join(github.event.pull_request.labels.*.name), 'sherlo:skip_build') }}
env:
BRANCH_NAME: ${{ github.event_name == 'pull_request' && github.head_ref || format('refs/heads/{0}', github.ref_name) }}
GITHUB_APP_TOKEN: ${{ steps.github_app_token.outputs.token }}
run: |
git config --global user.name 'Sherlo Bot'
git config --global user.email '[email protected]'
git add examples/expo-example/builds/preview
git commit -m "Update Preview builds"
git -c http.https://github.com/.extraheader="AUTHORIZATION: bearer ${GITHUB_APP_TOKEN}" push origin "${BRANCH_NAME}"
- name: Run Sherlo Action
uses: ./.
with:
ios: examples/expo-example/builds/preview/ios.tar.gz
android: examples/expo-example/builds/preview/android.apk
config: examples/expo-example/sherlo.config.json
env:
SHERLO_TOKEN: ${{ secrets.SHERLO_TOKEN }}