Skip to content

Commit

Permalink
feat(continuous-deploy-fingerprint): Add optional environment input f…
Browse files Browse the repository at this point in the history
…or EAS updates
  • Loading branch information
tharakadesilva committed Dec 5, 2024
1 parent 8108b86 commit d133508
Show file tree
Hide file tree
Showing 4 changed files with 41 additions and 24 deletions.
10 changes: 8 additions & 2 deletions build/continuous-deploy-fingerprint/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

32 changes: 18 additions & 14 deletions continuous-deploy-fingerprint/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@
## Overview

`continuous-deploy-fingerprint` is a GitHub Action continuously deploys an Expo project using the expo-updates fingerprint runtime version policy. When run, it performs the following tasks in order, once for each platform:

1. Check current fingerprint of the project.
2. Check for EAS builds with specified profile matching that fingerprint.
3. If a in-progress or finished EAS build doesn't exist, start one.
Expand All @@ -55,27 +56,29 @@
This action is customizable through variables defined in the [`action.yml`](action.yml).
Here is a summary of all the input options you can use.

| variable | default | description |
| --------------------- | -------------- | ---------------------------------------------------------------------------- |
| **profile** | (required) | The EAS Build profile to use |
| **branch** | (required) | The EAS Update branch on which to publish |
| **working-directory** | - | The relative directory of your Expo app |
| **platform** | `all` | The platform to deploy on (available options are `ios`, `android` and `all`) |
| **github-token** | `github.token` | GitHub token to use when commenting on PR ([read more](#github-tokens)) |
| variable | default | description |
| --------------- | ---------- | ------------------------------------------------------------------------ |
| **profile** | (required) | The EAS Build profile to use |
| **branch** | (required) | The EAS Update branch on which to publish |
| **environment** | - | The environment to use for server-side defined EAS environment variables |

| **working-directory** | - | The relative directory of your Expo app |
| **platform** | `all` | The platform to deploy on (available options are `ios`, `android` and `all`) |
| **github-token** | `github.token` | GitHub token to use when commenting on PR ([read more](#github-tokens)) |

And the action will generate these [outputs](#available-outputs) for other actions to do something based on what this action did.

### Available outputs

In case you want to reuse this action for other purpose, this action will set the following action outputs.

| output name | description |
| ------------------------ | ------------------------------ |
| **ios-fingerprint** | The iOS fingerprint of the current commit. |
| **android-fingerprint** | The Android fingerprint of the current commit. |
| **android-build-id** | ID for Android EAS Build if one was started. |
| **ios-build-id** | ID for iOS EAS Build if one was started. |
| **update-output** | The output (JSON) from the `eas update` command. |
| output name | description |
| ----------------------- | ------------------------------------------------ |
| **ios-fingerprint** | The iOS fingerprint of the current commit. |
| **android-fingerprint** | The Android fingerprint of the current commit. |
| **android-build-id** | ID for Android EAS Build if one was started. |
| **ios-build-id** | ID for iOS EAS Build if one was started. |
| **update-output** | The output (JSON) from the `eas update` command. |

## Caveats

Expand All @@ -93,6 +96,7 @@ You can read more about this in the [GitHub Actions documentation][link-actions]
### Continuously deploy after tests on main branch and pull requests

This workflow continuously deploys:

- main branch -> production EAS Build profile and EAS Update branch
- PR branches -> development EAS Build profile and EAS Update branch

Expand Down
3 changes: 3 additions & 0 deletions continuous-deploy-fingerprint/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,9 @@ inputs:
branch:
description: The EAS Update branch on which to publish.
required: true
environment:
description: The environment to use for server-side defined EAS environment variables during command execution
required: false
platform:
description: The platform on which to publish. Possible values are 'all' | 'android' | 'ios'
required: false
Expand Down
20 changes: 12 additions & 8 deletions src/actions/continuous-deploy-fingerprint.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ export function collectContinuousDeployFingerprintInput() {
platform: platformInput,
githubToken: getInput('github-token'),
workingDirectory: getInput('working-directory'),
environment: getInput('environment'),
};
}

Expand Down Expand Up @@ -71,6 +72,7 @@ export async function continuousDeployFingerprintAction(
const updates = await publishEASUpdatesAsync({
cwd: input.workingDirectory,
branch: input.branch,
environment: input.environment,
});

if (!isInPullRequest) {
Expand Down Expand Up @@ -293,20 +295,22 @@ async function createEASBuildAsync({
async function publishEASUpdatesAsync({
cwd,
branch,
environment,
}: {
cwd: string;
branch: string;
environment?: string;
}): Promise<EasUpdate[]> {
let stdout: string;
try {
const execOutput = await getExecOutput(
await which('eas', true),
['update', '--auto', '--branch', branch, '--non-interactive', '--json'],
{
cwd,
silent: !isDebug(),
}
);
const args = ['update', '--auto', '--branch', branch, '--non-interactive', '--json'];
if (environment) {
args.push('--environment', environment);
}
const execOutput = await getExecOutput(await which('eas', true), args, {
cwd,
silent: !isDebug(),
});
stdout = execOutput.stdout;
} catch (error: unknown) {
throw new Error(`Could not create a new EAS Update: ${String(error)}`);
Expand Down

0 comments on commit d133508

Please sign in to comment.