Skip to content

Commit 85cb0ca

Browse files
committed
fix: 🐛 handle post actions
1 parent 1af3528 commit 85cb0ca

File tree

2 files changed

+14
-5
lines changed

2 files changed

+14
-5
lines changed

src/index.ts

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,7 @@
1+
import { State } from './state'
12
import { Action } from './action'
23

3-
const isPost = !!process.env['STATE_isPost']
4-
5-
console.log(JSON.stringify(process.env, null, 2))
6-
7-
if (!isPost) {
4+
if (!State.isPost()) {
85
Action.run()
96
} else {
107
Action.cleanup()

src/state.ts

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
import * as coreCommand from '@actions/core/lib/command'
2+
3+
export namespace State {
4+
export const isPost = () => !!process.env['STATE_isPost']
5+
6+
// Publish a variable so that when the POST action runs, it can determine
7+
// it should run the cleanup logic. This is necessary since we don't have
8+
// a separate entry point.
9+
if (!isPost) {
10+
coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true')
11+
}
12+
}

0 commit comments

Comments
 (0)