Skip to content

Commit

Permalink
✨ feat: adding github action for eas build to main
Browse files Browse the repository at this point in the history
  • Loading branch information
andrew-bierman committed Apr 24, 2024
1 parent 73c9604 commit eee8ce6
Show file tree
Hide file tree
Showing 8 changed files with 313 additions and 22 deletions.
9 changes: 9 additions & 0 deletions .github/actions/install-deps/action.yml
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
41 changes: 41 additions & 0 deletions .github/actions/setup-eas/action.yml
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
42 changes: 23 additions & 19 deletions .github/workflows/labeler.yml → .github/labeler.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,17 @@ repo:
test:
- '**/*.spec.ts'
- '**/*.spec.js'
- '**/*.test.ts'
- '**/*.test.js'
- '**/tests/**/*.ts'
- '**/tests/**/*.js'


# Add 'frontend' label to any change in the 'client' directory
frontend:
- 'client/**/*.{ts,js}'
- any: ['client/**/*.ts', 'client/**/*.js']
all: ['!client/src/main.ts', '!client/src/main.js']
- 'apps/**/*.{ts,js}'
- any: ['apps/**/*.ts', 'apps/**/*.js']
all: ['!apps/src/main.ts', '!apps/src/main.js']

# Add 'backend' label to any change in the 'server' directory
backend:
Expand All @@ -24,19 +29,18 @@ AnyChange:
- '**/.*/**'
- '**/.*/**/.*'

# Workflow configuration starts here

name: Pull request labeler
on: [ pull_request_target ]

jobs:
triage:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/labeler@v4
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

client:
- apps/**/*

expo:
- apps/expo/**/*

next:
- apps/next/**/*

vite:
- apps/vite/**/*

api:
- api/**/*
- server/**/*
49 changes: 49 additions & 0 deletions .github/workflows/android-build-manual.yml
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
47 changes: 47 additions & 0 deletions .github/workflows/android-preview-build-local.yml
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
44 changes: 44 additions & 0 deletions .github/workflows/eas-build-manual.yml
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' || '' }}
6 changes: 3 additions & 3 deletions .github/workflows/label.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@
# file with configuration. For more information, see:
# https://github.com/actions/labeler

name: Labeler
on: [pull_request_target]
name: Pull request labeler
on: [ pull_request_target ]

jobs:
label:
Expand All @@ -17,6 +17,6 @@ jobs:
pull-requests: write

steps:
- uses: actions/labeler@v4
- uses: actions/labeler@v5
with:
repo-token: "${{ secrets.GITHUB_TOKEN }}"
97 changes: 97 additions & 0 deletions .github/workflows/tests.yml
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 }}

0 comments on commit eee8ce6

Please sign in to comment.