Skip to content

Commit

Permalink
ci: create simulator build when label is added to PR
Browse files Browse the repository at this point in the history
  • Loading branch information
edgarkhanzadian committed Sep 22, 2024
1 parent a5b7e40 commit c83076b
Show file tree
Hide file tree
Showing 3 changed files with 134 additions and 25 deletions.
105 changes: 105 additions & 0 deletions .github/actions/eas-deploy/action.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,105 @@
name: EAS deploy
description: Run EAS deploy
inputs:
EXPO_TOKEN: # id of input
description: 'Expo token'
required: true
APPLE_ID:
description: 'Apple ID'
required: true
ASC_APP_ID:
description: 'ASC App ID'
required: true
EXPO_APPLE_APP_SPECIFIC_PASSWORD:
description: 'Expo Apple app specific password'
required: true
LEATHER_BOT:
description: 'GH bot token'
required: true
runs:
using: 'composite'
steps:
- name: Prepare the app
uses: ./.github/actions/provision
- name: Extract branch name
shell: bash
run: echo "branch=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}" >> $GITHUB_OUTPUT
id: extract_branch
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
with:
eas-version: latest
token: ${{ inputs.EXPO_TOKEN }}
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install jq
shell: bash
- name: Setup eas credentials
run: |
echo $(jq --arg APPLE_ID "$APPLE_ID" '.submit.production.ios.appleId = $APPLE_ID' ./apps/mobile/eas.json) > ./apps/mobile/eas.json
echo $(jq --arg ASC_APP_ID "$ASC_APP_ID" '.submit.production.ios.ascAppId = $ASC_APP_ID' ./apps/mobile/eas.json) > ./apps/mobile/eas.json
shell: bash
env:
APPLE_ID: ${{ inputs.APPLE_ID }}
ASC_APP_ID: ${{ inputs.ASC_APP_ID }}
# Wait for build to either succeed or fail
- name: 🛫 Build for simulator 🛫
id: simulator_build
run: |
cd apps/mobile
if [[ "$BRANCH_NAME" == "dev" ]]
then
# No wait on simulator version build of the app if we are on a dev branch
eas build --platform ios --profile=simulator --non-interactive --no-wait
else
# set temporary command output
setTmpOutput () { tee /tmp/capture.out; }
# get temporary command output
getTmpOutput () { cat /tmp/capture.out; }
eas build --platform ios --profile=simulator --non-interactive | setTmpOutput
# Last line of the build output is the link to the expo build
UNSAFE_BUILD_LINK=$(getTmpOutput | tail -n 1)
if [[ $UNSAFE_BUILD_LINK == *"https://expo.dev/accounts/leather-wallet/projects/leather-wallet-mobile/builds/"* ]]; then
echo "Found build link!"
echo "BUILD_LINK=$UNSAFE_BUILD_LINK" >> $GITHUB_OUTPUT
else
echo "No build link!"
fi
fi
shell: bash
env:
EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ inputs.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
BRANCH_NAME: ${{ steps.extract_branch.outputs.branch }}
- name: Publish simulator expo link in PR
if: ${{ steps.extract_branch.outputs.branch != 'dev' }}
uses: actions/github-script@v7
env:
BUILD_LINK: ${{ steps.simulator_build.outputs.BUILD_LINK }}
with:
github-token: ${{ inputs.LEATHER_BOT }}
script: |
const { BUILD_LINK } = process.env
if(BUILD_LINK) {
github.rest.issues.createComment({
issue_number: context.issue.number,
owner: context.repo.owner,
repo: context.repo.repo,
body: "Expo simulator build link: " + BUILD_LINK
})
}
- name: 🛫 Build for production 🛫
if: ${{ steps.extract_branch.outputs.branch == 'dev' }}
run: |
cd apps/mobile
# Release version of the app, we should wait for it to see the result
eas build --platform ios --profile=production --non-interactive --auto-submit
shell: bash
env:
EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ inputs.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
25 changes: 25 additions & 0 deletions .github/workflows/eas-deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
on:
pull_request:
types:
- synchronize
- labeled

permissions:
contents: write
pull-requests: write

name: trigger EAS deploy

jobs:
deploy-eas:
if: contains(github.event.pull_request.labels.*.name, 'needs:demo-build')
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- uses: ./.github/actions/eas-deploy
with:
EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
ASC_APP_ID: ${{ secrets.ASC_APP_ID }}
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
LEATHER_BOT: ${{ secrets.LEATHER_BOT }}
29 changes: 4 additions & 25 deletions .github/workflows/release-please.yml
Original file line number Diff line number Diff line change
Expand Up @@ -77,31 +77,10 @@ jobs:
if: needs.release-please.outputs.releases_created
steps:
- uses: actions/checkout@v4
- name: Prepare the app
uses: ./.github/actions/provision
- name: Setup Expo and EAS
uses: expo/expo-github-action@v8
- uses: ./.github/actions/eas-deploy
with:
eas-version: latest
token: ${{ secrets.EXPO_TOKEN }}
- name: Install jq tool
run: |
sudo apt-get update
sudo apt-get install jq
- name: Setup eas credentials
run: |
echo $(jq --arg APPLE_ID "$APPLE_ID" '.submit.production.ios.appleId = $APPLE_ID' ./apps/mobile/eas.json) > ./apps/mobile/eas.json
echo $(jq --arg ASC_APP_ID "$ASC_APP_ID" '.submit.production.ios.ascAppId = $ASC_APP_ID' ./apps/mobile/eas.json) > ./apps/mobile/eas.json
env:
EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
APPLE_ID: ${{ secrets.APPLE_ID }}
ASC_APP_ID: ${{ secrets.ASC_APP_ID }}
# Wait for build to either succeed or fail
- name: 🛫 Prepare for takeoff! 🛫
run: |
cd apps/mobile
# No wait on simulator version build of the app
eas build --platform ios --profile=simulator --non-interactive --no-wait
# Release version of the app, we should wait for it to see the result
eas build --platform ios --profile=production --non-interactive --auto-submit
env:
EXPO_APPLE_APP_SPECIFIC_PASSWORD: ${{ secrets.EXPO_APPLE_APP_SPECIFIC_PASSWORD }}
EXPO_TOKEN: ${{ secrets.EXPO_TOKEN }}
LEATHER_BOT: ${{ secrets.LEATHER_BOT }}

0 comments on commit c83076b

Please sign in to comment.