-
Notifications
You must be signed in to change notification settings - Fork 41
Expand file tree
/
Copy pathpost.ts
More file actions
42 lines (34 loc) · 952 Bytes
/
post.ts
File metadata and controls
42 lines (34 loc) · 952 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
import * as core from '@actions/core'
import { exec } from '@actions/exec'
const run = async () => {
core.startGroup('Post cleanup script')
if (process.env.HAS_RUN_POST_JOB) {
core.info('Files already committed')
core.endGroup()
return
}
const files = JSON.parse(process.env.FILES || '[]')
const date = new Date().toISOString()
const meta = JSON.stringify(
{
date,
files,
},
undefined,
2
)
const msg = `Flat: latest data (${date})`
// Don't want to commit if there aren't any files changed!
if (!files.length) return
// these should already be staged, in main.ts
core.info(`Committing "${msg}"`)
core.debug(meta)
await exec('git', ['commit', '-m', msg + '\n\n' + meta])
await exec('git', ['push'])
core.info(`Pushed!`)
core.exportVariable('HAS_RUN_POST_JOB', 'true')
core.endGroup()
}
run().catch(error => {
core.setFailed('Post script failed! ' + error.message)
})