Skip to content

Commit

Permalink
fix: Fixing issues caused by updates loading
Browse files Browse the repository at this point in the history
fix: Preventing absurdly long waits between retries

chore: Re-building action

fix: Fixing async iterable error

fix: Changing how updates are parsed

fix: Please work
  • Loading branch information
skycoop committed Nov 13, 2021
1 parent 39f79c5 commit 96393dc
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 6 deletions.
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,8 @@ import { Endpoints } from '@octokit/types';
type Octokit = ReturnType<typeof github.getOctokit>;
type Tree = Endpoints['POST /repos/{owner}/{repo}/git/trees']['parameters']['tree'];

type Updates = Map<string, Map<string, any>>;
type Change = [string, any];
type Update = [string, Change[]];

function isFileMode(str: string): str is '100644' | '100755' {
return str === '100644' || str === '100755';
Expand All @@ -28,7 +29,7 @@ async function commitUpdates(
repo: string,
branch: string,
message: string,
updates: Updates
updates: Update[]
): Promise<string> {
const ref = `heads/${branch}`;
let baseRef;
Expand Down Expand Up @@ -156,16 +157,20 @@ async function run(): Promise<void> {
message += `\nCommit made by Github Actions ${url}`;
}

const updates: Updates = getYamlInput('updates', { required: true });
const rawUpdates = getYamlInput('updates', { required: true });
const updates = <Update[]>(<unknown>_.entries(_.mapValues(rawUpdates, _.entries)));
const retries = getIntegerInput('retries');

let sha: string;
try {
sha = await retry(async () => await commitUpdates(octokit, owner, repo, branch, message, updates), {
retries,
onRetry: (err) => {
core.warning(`Error while performing commit: ${err}`);
core.warning(`Error while performing commit: ${err}\n${err.stack}`);
},
minTimeout: 100,
maxTimeout: 5_000,
randomize: false,
});
} catch (err) {
throw new Error(`Could not perform commit after ${retries + 1} attempts: ${err}`);
Expand Down

0 comments on commit 96393dc

Please sign in to comment.