Skip to content

Commit e42d1af

Browse files
committed
feat: ✨ export environment varibale
1 parent e675890 commit e42d1af

File tree

3 files changed

+13
-4
lines changed

3 files changed

+13
-4
lines changed

src/action.ts

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,14 @@ export namespace Action {
1111
await Util.saveAppTokenToSecret(secretName, token)
1212
core.info(`Token save in secret "${secretName}"`)
1313
}
14+
1415
core.setSecret(token)
1516
core.setOutput('token', token)
17+
18+
const variableName = core.getInput('VARIABLE_NAME')
19+
if (variableName) {
20+
core.exportVariable(variableName, token)
21+
}
1622
} catch (e) {
1723
core.error(e)
1824
core.setFailed(e.message)

src/index.ts

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
1+
import { getInput } from '@actions/core'
12
import { State } from './state'
23
import { Action } from './action'
34

45
if (!State.isPost) {
56
Action.run()
67
} else {
7-
Action.cleanup()
8+
if (getInput('CLEAN_SECRET') === 'true') {
9+
Action.cleanup()
10+
}
811
}

src/state.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
import * as coreCommand from '@actions/core/lib/command'
1+
import { getState, saveState } from '@actions/core'
22

33
export namespace State {
4-
export const isPost = !!process.env['STATE_isPost']
4+
export const isPost = !!getState('isPost')
55

66
// Publish a variable so that when the POST action runs, it can determine
77
// it should run the cleanup logic. This is necessary since we don't have
88
// a separate entry point.
99
if (!isPost) {
10-
coreCommand.issueCommand('save-state', { name: 'isPost' }, 'true')
10+
saveState('isPost', true)
1111
}
1212
}

0 commit comments

Comments
 (0)