Skip to content

Commit

Permalink
docs: add examples and more contextual info
Browse files Browse the repository at this point in the history
  • Loading branch information
byCedric committed Apr 10, 2019
1 parent a401e30 commit 9625bb1
Showing 1 changed file with 114 additions and 16 deletions.
130 changes: 114 additions & 16 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,19 +1,58 @@
# Expo for GitHub Actions

> Both GitHub Actions and this library are highly unstable, do not use in production (yet).
> GitHub Actions is still in beta, use it at your own risk.
Publish, build or manage your [Expo](https://expo.io) Project with GitHub Actions!
Publish, build or manage your [Expo][link-expo] Project with GitHub Actions!
This repository contains a prebuilt base image with GitHub Actions implementations.
You can also use [the base image](base) in other Docker-based environments.

## Usage
## What's inside?

Below you can see an example workflow to get you started right away!
Within this Expo CLI action, you have full access to the original [Expo CLI][link-expo-cli].
That means you are able to perform any command like login, publish and build.
Also, this action will authenticate automatically when both `EXPO_USERNAME` and `EXPO_PASSWORD` variables are defined.

> Check out both [login](./login) and [publish](./publish) actions for more info.
> You don't necessarily need this action to use Expo.
> You can also add `expo-cli` as a dependency to your project and use the official [NPM action][link-actions-npm] for example.
> However, when you do that you need to manage authentication yourself.
### Why use a base-image?

Every GitHub action will start from scratch, using the dockerfile as the starting point.
If you define `expo-cli` in this dockerfile, it will install it every time you run an action.
By using a prebuilt image, it basically "skips" the process of downloading the full CLI over and over again.
This makes the Expo actions overall faster.

### Used secrets

To authenticate with your Expo account, use the variables listed below.
In the Expo action you can define `secrets = ["EXPO_USERNAME", "EXPO_PASSWORD"]` to have them available.

variable | description
--- | ---
`EXPO_USERNAME` | The email address or username of your Expo account.
`EXPO_PASSWORD` | The password of your Expo account.

> Some Expo commands don't require authentication.
> Simply omit the `secrets = [...]` if you don't need it.
## Example workflows

Before you dive into the workflow examples, you should know the basics of GitHub Actions.
You can read more about this in the [GitHub Actions documentation][link-actions].

1. [Publish on any push](#publish-on-any-push)
2. [Publish on a specific branch](#publish-on-a-specific-branch)
3. [Test and build web every day at 08:00](#test-and-build-web-every-day-at-0800)

### Publish on any push

Below you can see the example configuration to publish whenever the repository is updated.
The workflow listens to the `push` event and resolves directly to the `publish` action.
Before publishing your app, it installs your project's dependencies using the [NPM action][link-actions-npm].

```hcl
workflow "Install, Authenticate, and Publish" {
workflow "Install and Publish" {
on = "push"
resolves = ["Publish"]
}
Expand All @@ -23,28 +62,82 @@ action "Install" {
args = "install"
}
action "Authenticate" {
action "Publish" {
needs = "Install"
uses = "bycedric/ci-expo/login@master"
uses = "bycedric/ci-expo@master"
args = "publish"
secrets = ["EXPO_USERNAME", "EXPO_PASSWORD"]
}
```

### Publish on a specific branch

This workflow is similar to the [publish on any push](#publish-on-any-push) configuration.
It will install and test the code using the [NPM action][link-actions-npm] on every push.
But instead of publishing on any push too, it will publish on the `master` branch only.

```hcl
workflow "Install and Publish" {
on = "push"
resolves = ["Publish"]
}
action "Install" {
uses = "actions/npm@master"
args = "install"
}
action "Test" {
needs = "Install"
uses = "actions/npm@master"
args = "test"
}
action "Filter branch" {
needs = "Test"
uses = "actions/bin/filter@master"
args = "branch master"
}
action "Publish" {
needs = "Authenticate"
uses = "bycedric/ci-expo/publish@master"
needs = "Filter branch"
uses = "bycedric/ci-expo@master"
args = "publish"
secrets = ["EXPO_USERNAME", "EXPO_PASSWORD"]
}
```

### Custom command
### Test and build web every day at 08:00

By default, you have full access to the actual [Expo CLI](https://docs.expo.io/versions/latest/workflow/expo-cli).
That means that you should be able to use every function from the CLI in your actions.
Below you can see how a custom command can be defined.
You can add as many extra steps in a workflow as you want.
Here we've added a test step, that basically invokes `npm test` using the [NPM action][link-actions-npm].
It also doesn't listen to push events.
Instead, it's scheduled to run every day at 08:00.

> For web builds, you don't need to be authenticated.
> That's why `secrets = [...]` is omitted here.
```hcl
action "Doctor" {
workflow "Install, Test and Build Web" {
on = "schedule(0 8 * * *)"
resolves = ["Publish"]
}
action "Install" {
uses = "actions/npm@master"
args = "install"
}
action "Test" {
needs = "Install"
uses = "actions/npm@master"
args = "test"
}
action "Publish" {
needs = "Test"
uses = "bycedric/ci-expo@master"
args = "doctor"
args = "build:web"
}
```

Expand All @@ -57,3 +150,8 @@ The MIT License (MIT). Please see [License File](LICENSE.md) for more informatio
<p align="center">
with :heart: <a href="https://bycedric.com" target="_blank">byCedric</a>
</p>

[link-actions]: https://developer.github.com/actions/
[link-actions-npm]: https://github.com/actions/npm
[link-expo]: https://expo.io
[link-expo-cli]: https://docs.expo.io/versions/latest/workflow/expo-cli

0 comments on commit 9625bb1

Please sign in to comment.