Skip to content

Commit

Permalink
Add post action run script to commit all files instead of committing …
Browse files Browse the repository at this point in the history
…per step
  • Loading branch information
Irene Alvarado committed Apr 13, 2021
1 parent e298798 commit e10c1dd
Show file tree
Hide file tree
Showing 8 changed files with 1,755 additions and 49 deletions.
1 change: 1 addition & 0 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ outputs:
runs:
using: 'node12'
main: 'dist/index.js'
post: 'dist/post/index.js'
branding:
color: 'purple'
icon: 'download-cloud'
19 changes: 6 additions & 13 deletions dist/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -498,20 +498,13 @@ async function run() {
const bytes = await git_1.diff(filename);
core.setOutput('delta_bytes', bytes);
core.endGroup();
if (bytes === 0) {
return;
}
core.startGroup('Committing new data');
const sign = bytes >= 0 ? '+' : '';
const date = new Date().toISOString();
const msg = `Latest data: ${date} (${sign}${bytes}b)`;
const meta = JSON.stringify({
files: [{ name: filename, deltaBytes: bytes, date, source }],
}, undefined, 2);
core.info(`Committing "${msg}"`);
core.debug(meta);
await exec_1.exec('git', ['commit', '-m', msg + '\n' + meta]);
await exec_1.exec('git', ['push']);
const alreadyEditedFiles = JSON.parse(process.env.FILES || "[]");
core.info("alreadyEditedFiles");
core.info(JSON.stringify(alreadyEditedFiles));
const newFiles = [{ name: filename, deltaBytes: bytes, source }]; // TODO: add other files
const files = [...alreadyEditedFiles, ...newFiles];
core.exportVariable('FILES', files);
core.endGroup();
}
run().catch(error => {
Expand Down
2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit e10c1dd

Please sign in to comment.