Skip to content

Commit

Permalink
fix: remove broken outputs
Browse files Browse the repository at this point in the history
  • Loading branch information
EdieLemoine committed Apr 12, 2024
1 parent 4f83ef7 commit c3896da
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 26 deletions.
6 changes: 2 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# Monodeploy GitHub Actions plugin

This is a small plugin for [Monodeploy](https://github.com/tophat/monodeploy) that adds information about the release to `$GITHUB_OUTPUT`, for use with GitHub actions. This is useful for letting other actions/workflows depend on the result of a monodeploy run. For example, to only execute something if a release was done.
This is a small plugin for [Monodeploy](https://github.com/tophat/monodeploy) that adds information about whether a release happened to `$GITHUB_OUTPUT`, for use with GitHub actions. This is useful for letting other actions/workflows depend on the result of a monodeploy run. For example, to only execute something if a release was done.

## Usage

Expand Down Expand Up @@ -28,7 +28,5 @@ module.exports = {
- name: "Do something with output"
if: steps.release.outputs.released == 'true'
run: |
echo ${{ steps.release.outputs.lastVersion }}
echo ${{ steps.release.outputs.nextVersion }}
echo ${{ steps.release.outputs.releaseType }}
echo 'do something'
```
25 changes: 3 additions & 22 deletions src/index.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,5 @@
import * as os from "node:os";
import * as fs from "node:fs";
import {
type PluginHooks,
type YarnContext,
type MonodeployConfiguration,
type ChangesetSchema,
} from "@monodeploy/types";
import { type PluginHooks } from "@monodeploy/types";

// eslint-disable-next-line @typescript-eslint/naming-convention
export const PluginName = "GitHub Actions Plugin";
Expand All @@ -14,25 +8,12 @@ export const PluginName = "GitHub Actions Plugin";
export default function GithubActionsPlugin({
onReleaseAvailable,
}: Pick<PluginHooks, "onReleaseAvailable">): void {
const outputReleaseInformation = async (
context: YarnContext,
config: MonodeployConfiguration,
changeset: ChangesetSchema
): Promise<void> => {
const outputReleaseInformation = async (): Promise<void> => {
if (!process.env.GITHUB_OUTPUT) {
return;
}

const { lastRelease, nextRelease } = changeset;

const output = [
`released=true`,
`last-version=${lastRelease.version}`,
`next-version=${nextRelease.version}`,
`release-type=${nextRelease.strategy}`,
].join(os.EOL);

await fs.promises.appendFile(process.env.GITHUB_OUTPUT, output);
await fs.promises.appendFile(process.env.GITHUB_OUTPUT, "released=true");
};

onReleaseAvailable.tapPromise(PluginName, outputReleaseInformation);
Expand Down

0 comments on commit c3896da

Please sign in to comment.