Skip to content

Commit

Permalink
v3 (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
keroxp authored Dec 2, 2020
1 parent d94e7ee commit f90a6ae
Show file tree
Hide file tree
Showing 11 changed files with 2,472 additions and 753 deletions.
16 changes: 16 additions & 0 deletions .github/workflows/push.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
name: CI
on: [push]
jobs:
test:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: actions/setup-node@v1
with:
node-version: "14"
- run: yarn install
- name: Check lib
run: |
make
git diff --exit-code
- run: yarn test
5 changes: 2 additions & 3 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
dist/index.js: index.ts package.json yarn.lock
yarn tsc
yarn ncc build dist/index.js
lib/index.js: index.ts src/setup.ts package.json yarn.lock
yarn ncc build index.ts -o lib
18 changes: 15 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,15 +1,27 @@
# actions-setup-cage
Github Actions to setup [canarycage](https://github.com/loilo-inc/canarycage)

# Usage
## Usage

```yml
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- uses: loilo-inc/[email protected]
- uses: loilo-inc/actions-setup-cage@{version}
```
## Cage Version
By default, if no `cage-version` specified in step parameters, the latest version of cage will be resolved and installed automatically. **This is highly recommended.**

If you need to set specified version of cage, add `cage-version` param.

```yaml
- uses: loilo-inc/actions-setup-cage@{version}
with:
cage-version: 3.4.0
cage-version: 3.4.2
```
5 changes: 2 additions & 3 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,8 @@ description: 'Download and add cage to the PATH'
author: 'LoiLo'
inputs:
cage-version:
description: 'Cage version'
default: '3.4.0'
description: "Canarycage version. If no version specified, the latest version will be used automatically."
required: false
runs:
using: 'node12'
main: 'dist/index.js'
main: 'lib/index.js'
26 changes: 13 additions & 13 deletions index.ts
Original file line number Diff line number Diff line change
@@ -1,20 +1,20 @@
import * as core from "@actions/core";
import * as tc from "@actions/tool-cache";

export async function downloadCage({ version }: { version: string }) {
console.log("🥚 Installing cage...");
const url = `https://github.com/loilo-inc/canarycage/releases/download/${version}/canarycage_linux_amd64.zip`
const zip = await tc.downloadTool(url);
const extracted = await tc.extractZip(zip);
const installed = await tc.cacheDir(extracted, "cage", version);
core.addPath(installed);
console.log(`🐣 cage has been installed at '${installed}/cage'`);
}
import * as io from "@actions/io"
import {downloadCage, getLatestVersion} from "./src/setup";

async function main() {
try {
const version = core.getInput("cage-version");
await downloadCage({ version });
let version = core.getInput("cage-version");
const latestVersion = await getLatestVersion()
if (!version) {
version = latestVersion
core.info(`No version specified. Using latest version: ${version}`)
} else if (version !== latestVersion) {
core.warning(`New version of cage found: current=${version}, latest=${latestVersion}`)
}
if (!(await io.which("cage", false))) {
await downloadCage({version});
}
} catch (error) {
core.setFailed(error.message);
}
Expand Down
Loading

0 comments on commit f90a6ae

Please sign in to comment.