2022-03-27 19:48:50 -07:00
# Setup Earthly - GitHub Action
2021-04-20 15:28:53 -07:00
2022-03-27 19:48:50 -07:00
This repository contains an action for use with GitHub Actions, which installs [earthly ](https://github.com/earthly/earthly ) with a semver-compatible version.
The package is installed into `/home/runner/.earthly` (or equivalent on Windows) and the `bin` subdirectory is added to the PATH.
## Usage
Full example:
2021-04-20 15:28:53 -07:00
```yml
name: GitHub Actions CI
on:
push:
2022-03-27 19:48:50 -07:00
branches: [main]
2021-04-20 15:28:53 -07:00
pull_request:
2022-03-27 19:48:50 -07:00
branches: [main]
2021-04-20 15:28:53 -07:00
jobs:
tests:
name: example earthly test
runs-on: ubuntu-latest
steps:
2022-03-10 12:10:21 -08:00
- uses: earthly/actions-setup@v1
2021-04-20 15:28:53 -07:00
with:
2023-03-02 10:52:26 -08:00
version: "latest" # or pin to an specific version, e.g. "0.7.1"
2021-04-20 15:28:53 -07:00
- uses: actions/checkout@v2
2022-03-10 13:34:07 -08:00
- name: Docker login # to avoid dockerhub rate-limiting
run: docker login --username "${{ secrets.DOCKERHUB_USERNAME }}" --password "${{ secrets.DOCKERHUB_PASSWORD }}"
2021-04-20 15:28:53 -07:00
- name: what version is installed?
run: earthly --version
- name: run the earthly hello world
run: earthly github.com/earthly/hello-world:main+hello
```
2021-04-21 11:02:16 -07:00
2022-04-18 18:30:58 -07:00
Install the latest version of earthly:
2022-03-27 19:48:50 -07:00
```yaml
- name: Install earthly
2023-01-19 10:53:57 -06:00
uses: earthly/actions-setup@v1
2022-03-27 19:48:50 -07:00
```
2022-04-18 18:30:58 -07:00
Install a specific version of earthly:
2022-03-27 19:48:50 -07:00
```yaml
- name: Install earthly
2023-01-19 10:53:57 -06:00
uses: earthly/actions-setup@v1
2022-03-27 19:48:50 -07:00
with:
version: 0.6.1
```
Install a version that adheres to a semver range
```yaml
- name: Install earthly
2023-01-19 10:53:57 -06:00
uses: earthly/actions-setup@v1
2022-03-27 19:48:50 -07:00
with:
version: ^0.6.0
```
### Testing
2022-04-21 14:08:59 -07:00
You can perform a local test by running `earthly +all` .
It is also possible to use [act ](https://github.com/nektos/act ) to test the contents of the github actions config.
2022-03-27 19:48:50 -07:00
## Configuration
The action can be configured with the following arguments:
- `version` - The version of earthly to install. Default is `latest` . Accepts semver style values.
- `github-token` (optional) - Token used to query earthly versions.
2023-02-22 21:31:17 +01:00
- `prerelease` (optional) - allow prerelease versions.
- `use-cache` (optional) - whether to use the cache to store earthly or not.