-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #866 from andrew-bierman/feat/eas-action-main
✨ feat: adding github action for eas build to main
- Loading branch information
Showing
8 changed files
with
313 additions
and
22 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
name: 'Install Dependencies' | ||
description: 'Install Node.js dependencies' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Install dependencies | ||
run: yarn install --frozen-lockfile | ||
shell: bash |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
name: 'Setup EAS' | ||
description: 'Set up EAS and install dependencies' | ||
|
||
inputs: | ||
expo-token: | ||
description: 'Expo token for authentication' | ||
required: true | ||
node-version: | ||
description: 'Node.js version to use' | ||
required: true | ||
default: '20.x' | ||
|
||
runs: | ||
using: 'composite' | ||
steps: | ||
- name: Check for EXPO_TOKEN | ||
run: | | ||
if [ -z "${{ inputs.expo-token }}" ]; then | ||
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions" | ||
exit 1 | ||
fi | ||
shell: bash | ||
|
||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ inputs.node-version }} | ||
cache: yarn | ||
|
||
- name: Setup EAS | ||
uses: expo/expo-github-action@v8 | ||
with: | ||
eas-version: latest | ||
token: ${{ inputs.expo-token }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
shell: bash |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
name: android build manual | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
name: | ||
description: 'Build manually' | ||
default: 'World' | ||
required: true | ||
type: string | ||
|
||
jobs: | ||
update: | ||
name: EAS Android Preview Build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: Check for EXPO_TOKEN | ||
run: | | ||
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then | ||
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions" | ||
exit 1 | ||
fi | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
cache: yarn | ||
|
||
- name: Setup EAS | ||
uses: expo/expo-github-action@v8 | ||
with: | ||
eas-version: latest | ||
token: ${{ secrets.EXPO_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Create preview | ||
uses: expo/expo-github-action/preview@v8 | ||
with: | ||
working-directory: apps/expo | ||
command: eas build --platform android --profile preview |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: android-preview-build-local | ||
on: | ||
push: | ||
branches: [ "**" ] | ||
pull_request: | ||
branches: [ "**" ] | ||
|
||
|
||
|
||
jobs: | ||
update: | ||
name: EAS Android Preview Build Local | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
steps: | ||
- name: Check for EXPO_TOKEN | ||
run: | | ||
if [ -z "${{ secrets.EXPO_TOKEN }}" ]; then | ||
echo "You must provide an EXPO_TOKEN secret linked to this project's Expo account in this repo's secrets. Learn more: https://docs.expo.dev/eas-update/github-actions" | ||
exit 1 | ||
fi | ||
- name: Checkout repository | ||
uses: actions/checkout@v3 | ||
|
||
- name: Setup Node | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: 20.x | ||
cache: yarn | ||
|
||
- name: Setup EAS | ||
uses: expo/expo-github-action@v8 | ||
with: | ||
eas-version: latest | ||
token: ${{ secrets.EXPO_TOKEN }} | ||
|
||
- name: Install dependencies | ||
run: yarn install | ||
|
||
- name: Create preview | ||
uses: expo/expo-github-action/preview@v8 | ||
with: | ||
working-directory: apps/expo | ||
command: eas build --platform android --profile preview --local |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
name: EAS Build Manual | ||
|
||
on: | ||
workflow_dispatch: | ||
inputs: | ||
platform: | ||
description: 'Platform (android or ios)' | ||
required: true | ||
default: 'android' | ||
type: choice | ||
options: | ||
- android | ||
- ios | ||
build-type: | ||
description: 'Build type (preview or local)' | ||
required: true | ||
default: 'preview' | ||
type: choice | ||
options: | ||
- preview | ||
- local | ||
|
||
jobs: | ||
update: | ||
name: EAS ${{ github.event.inputs.platform }} ${{ github.event.inputs.build-type }} Build | ||
runs-on: ubuntu-latest | ||
permissions: | ||
contents: read | ||
pull-requests: write | ||
|
||
steps: | ||
- name: Setup EAS | ||
uses: ./.github/actions/setup-eas | ||
with: | ||
expo-token: ${{ secrets.EXPO_TOKEN }} | ||
node-version: '20.x' | ||
|
||
- name: Create build | ||
uses: expo/expo-github-action/preview@v8 | ||
with: | ||
working-directory: apps/expo | ||
command: | | ||
eas build --platform ${{ github.event.inputs.platform }} --profile preview \ | ||
${{ github.event.inputs.build-type == 'local' && '--local' || '' }} |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
name: Run Tests | ||
|
||
on: | ||
push: | ||
branches: ['**'] | ||
pull_request: | ||
branches: ['**'] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- uses: actions/checkout@v3 | ||
|
||
- name: Use Node.js | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: '20.x' | ||
|
||
- name: Find or create comment | ||
uses: actions/github-script@v6 | ||
id: find_or_create_comment | ||
if: github.event_name == 'pull_request' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const commentIdentifier = '<!-- test_results -->'; | ||
const commentBody = `${commentIdentifier}\n🚀 Running tests... Please wait for the results! 🕐`; | ||
const comments = await github.rest.issues.listComments({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
}); | ||
const existingComment = comments.data.find(comment => comment.body.startsWith(commentIdentifier)); | ||
if (existingComment) { | ||
core.setOutput('comment_id', existingComment.id); | ||
} else { | ||
const { data: { id: commentId } } = await github.rest.issues.createComment({ | ||
issue_number: context.issue.number, | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
body: commentBody | ||
}); | ||
core.setOutput('comment_id', commentId); | ||
} | ||
- name: Install dependencies | ||
uses: ./.github/actions/install-deps | ||
|
||
- name: Run tests | ||
id: run_tests | ||
run: | | ||
yarn test | ||
continue-on-error: true | ||
|
||
- name: Update comment with test results | ||
uses: actions/github-script@v6 | ||
if: always() && github.event_name == 'pull_request' | ||
with: | ||
github-token: ${{ secrets.GITHUB_TOKEN }} | ||
script: | | ||
const commentId = process.env.COMMENT_ID; | ||
const testLogs = `${{ steps.run_tests.outputs.stdout }}\n${{ steps.run_tests.outputs.stderr }}`; | ||
const testStatus = `${{ steps.run_tests.outcome }}`; | ||
let commentBody = '<!-- test_results -->\n'; | ||
let emoji = ''; | ||
if (testStatus === 'success') { | ||
commentBody += '✅ Tests passed successfully! 🎉\n\n'; | ||
emoji = '💚'; | ||
} else { | ||
commentBody += '❌ Tests failed for this pull request. 😞\n\n'; | ||
emoji = '❤️'; | ||
} | ||
commentBody += `<details><summary>Test Logs</summary>\n\n\`\`\`\n${testLogs}\n\`\`\`\n</details>`; | ||
await github.rest.issues.updateComment({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
comment_id: commentId, | ||
body: commentBody | ||
}); | ||
await github.rest.issues.addLabels({ | ||
owner: context.repo.owner, | ||
repo: context.repo.repo, | ||
issue_number: context.issue.number, | ||
labels: [`tests-${testStatus}${emoji}`] | ||
}); | ||
env: | ||
COMMENT_ID: ${{ steps.find_or_create_comment.outputs.comment_id }} |