Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Merge pull request #61 from crazy-max/exec-output
Use built-in getExecOutput
  • Loading branch information
CrazyMax authored and GitHub committed Oct 8, 2022
2 parents aa08745 + f3c51a3 commit 8c1e35a
Show file tree
Hide file tree
Showing 5 changed files with 23 additions and 64 deletions.
27 changes: 8 additions & 19 deletions README.md
Expand Up @@ -13,7 +13,7 @@ ___
* [Usage](#usage)
* [Customizing](#customizing)
* [inputs](#inputs)
* [Keep up-to-date with GitHub Dependabot](#keep-up-to-date-with-github-dependabot)
* [Contributing](#contributing)

## Usage

Expand All @@ -38,10 +38,10 @@ jobs:

Following inputs can be used as `step.with` keys

| Name | Type | Description |
|------------------|---------|------------------------------------|
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |
| Name | Type | Description |
|-------------|--------|---------------------------------------------------------------------------------------------------------------------------|
| `image` | String | QEMU static binaries Docker image (default [`tonistiigi/binfmt:latest`](https://hub.docker.com/r/tonistiigi/binfmt/tags)) |
| `platforms` | String | Platforms to install (e.g. `arm64,riscv64,arm` ; default `all`) |

### outputs

Expand All @@ -51,18 +51,7 @@ Following outputs are available
|---------------|---------|---------------------------------------|
| `platforms` | String | Available platforms (comma separated) |

## Keep up-to-date with GitHub Dependabot
## Contributing

Since [Dependabot](https://docs.github.com/en/github/administering-a-repository/keeping-your-actions-up-to-date-with-github-dependabot)
has [native GitHub Actions support](https://docs.github.com/en/github/administering-a-repository/configuration-options-for-dependency-updates#package-ecosystem),
to enable it on your GitHub repo all you need to do is add the `.github/dependabot.yml` file:

```yaml
version: 2
updates:
# Maintain dependencies for GitHub Actions
- package-ecosystem: "github-actions"
directory: "/"
schedule:
interval: "daily"
```
Want to contribute? Awesome! You can find information about contributing to
this project in the [CONTRIBUTING.md](/.github/CONTRIBUTING.md)
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

34 changes: 0 additions & 34 deletions src/exec.ts

This file was deleted.

22 changes: 13 additions & 9 deletions src/main.ts
@@ -1,4 +1,3 @@
import * as mexec from './exec';
import * as core from '@actions/core';
import * as exec from '@actions/exec';
import {issueCommand} from '@actions/core/lib/command';
Expand Down Expand Up @@ -31,14 +30,19 @@ async function run(): Promise<void> {
core.endGroup();

core.startGroup(`Extracting available platforms`);
await mexec.exec(`docker`, ['run', '--rm', '--privileged', image], true).then(res => {
if (res.stderr != '' && !res.success) {
throw new Error(res.stderr);
}
const platforms: Platforms = JSON.parse(res.stdout.trim());
core.info(`${platforms.supported.join(',')}`);
setOutput('platforms', platforms.supported.join(','));
});
await exec
.getExecOutput('docker', ['run', '--rm', '--privileged', image], {
ignoreReturnCode: true,
silent: true
})
.then(res => {
if (res.stderr.length > 0 && res.exitCode != 0) {
throw new Error(res.stderr.trim());
}
const platforms: Platforms = JSON.parse(res.stdout.trim());
core.info(`${platforms.supported.join(',')}`);
setOutput('platforms', platforms.supported.join(','));
});
core.endGroup();
} catch (error) {
core.setFailed(error.message);
Expand Down

0 comments on commit 8c1e35a

Please sign in to comment.