Skip to content

Commit

Permalink
update workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
ericfennis committed Dec 13, 2023
1 parent 73f70c8 commit e32db96
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 11 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/pull-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ jobs:
runs-on: ubuntu-latest
permissions:
contents: read
pull-requests: write
steps:
- uses: actions/checkout@v3
with:
Expand All @@ -29,7 +28,7 @@ jobs:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
FETCH_DEPTH: ${{ github.event.pull_request.commits }}
CHANGED_FILES: ${{ steps.changed-files.outputs.all_changed_files }}
run: node ./scripts/updateContributors.mjs "$CHANGED_FILES"
run: node ./scripts/updateContributors.mjs
- name: Generate annotations
env:
ANNOTATION_SEVERITY: notice
Expand Down
17 changes: 8 additions & 9 deletions scripts/updateContributors.mjs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import simpleGit from 'simple-git';
import { Octokit } from '@octokit/rest';
import fs from 'node:fs';
import path from 'path';
import simpleGit from 'simple-git';
import { Octokit } from '@octokit/rest';
import pMemoize from 'p-memoize';

const IGNORED_COMMITS = ['433bbae4f1d4abb50a26306d6679a38ace5c8b78'];
Expand All @@ -25,7 +25,7 @@ const getUserName = pMemoize(
}
return fetchedCommit?.author?.login;
},
{ cacheKey: ([commit]) => commit.author_email, cache }
{ cacheKey: ([commit]) => commit.author_email, cache },
);

// Check that a commit changes more than just the icon name
Expand All @@ -51,7 +51,7 @@ const getContributors = async (file, includeCoAuthors) => {
}
if (includeCoAuthors) {
const matches = commit.body.matchAll(
/(^Author:|^Co-authored-by:)\s+(?<author>[^<]+)\s+<(?<email>[^>]+)>/gm
/(^Author:|^Co-authored-by:)\s+(?<author>[^<]+)\s+<(?<email>[^>]+)>/gm,
);
// eslint-disable-next-line no-restricted-syntax
for (const match of matches) {
Expand All @@ -66,8 +66,7 @@ const getContributors = async (file, includeCoAuthors) => {
return Promise.all(Array.from(emails.values()));
};

const files = process.argv
.slice(2)
const files = process.env.CHANGED_FILES.slice(2)
.map((file) => file.replace('.json', '.svg'))
.filter((file, idx, arr) => arr.indexOf(file) === idx);

Expand Down Expand Up @@ -100,8 +99,8 @@ await Promise.all(
...rest,
},
null,
2
)
2,
),
);
})
}),
);

0 comments on commit e32db96

Please sign in to comment.