Skip to content

Commit

Permalink
Merge pull request #17 from gregsdennis/custom-domains
Browse files Browse the repository at this point in the history
Custom domains
  • Loading branch information
gregsdennis committed Aug 24, 2023
2 parents 71c5cc1 + 9aa92ae commit e1985f2
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 6 deletions.
8 changes: 6 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,13 @@ The action can detect links in the following styles:
- Quick Link: `#5`
- Partial Link: `gregsdennis/dependencies-action#5`
- Partial URL: `gregsdennis/dependencies-action/pull/5`
- Full URL: `http://github.com/gregsdennis/dependencies-action/pull/5`
- Markdown: `[markdown link](http://github.com/gregsdennis/dependencies-action/pull/5)`
- Full URL: `https://github.com/gregsdennis/dependencies-action/pull/5`
- Markdown: `[markdown link](https://github.com/gregsdennis/dependencies-action/pull/5)`

Works for both issues and PRs!

Also supports custom domains for use with GitHub Enterprise!

## See it in action:

- [PR to be landed first](http://github.com/gregsdennis/dependencies-action/pull/4)
Expand All @@ -34,6 +36,8 @@ jobs:
name: Check Dependencies
steps:
- uses: gregsdennis/dependencies-action@main
with:
custom-domains: my-custom-domain.io another.domain.com
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
7 changes: 6 additions & 1 deletion action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,4 +5,9 @@ branding:
color: orange
runs:
using: 'node16'
main: 'index.js'
main: 'index.js'
inputs:
custom-domains:
description: 'Space-delimited list of custom domains where issues may be found'
required: false
default: null
19 changes: 16 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,26 @@
const core = require('@actions/core');
const github = require('@actions/github');

var customDomains = core.getInput('custom-domains')?.split(/(\s+)/) ?? [];

const keyPhrases = 'depends on|blocked by';
const issueTypes = 'issues|pull'
const issueTypes = 'issues|pull';
const domainsList = ['github.com'].concat(customDomains); // add others from parameter
const domainsString = combineDomains(domainsList);

const quickLinkRegex = new RegExp(`(${keyPhrases}) #(\\d+)`, 'gmi');
const partialLinkRegex = new RegExp(`(${keyPhrases}) ([-_\\w]+)\\/([-._a-z0-9]+)(#)(\\d+)`, 'gmi');
const partialUrlRegex = new RegExp(`(${keyPhrases}) ([-_\\w]+)\\/([-._a-z0-9]+)\\/(${issueTypes})\\/(\\d+)`, 'gmi');
const fullUrlRegex = new RegExp(`(${keyPhrases}) https:\\/\\/github\\.com\\/([-_\\w]+)\\/([-._a-z0-9]+)\\/(${issueTypes})\\/(\\d+)`, 'gmi');
const markdownRegex = new RegExp(`(${keyPhrases}) \\[.*\\]\\(https:\\/\\/github\\.com\\/([-_\\w]+)\\/([-._a-z0-9]+)\\/(${issueTypes})\\/(\\d+)\\)`, 'gmi');
const fullUrlRegex = new RegExp(`(${keyPhrases}) https?:\\/\\/(?:${domainsString})\\/([-_\\w]+)\\/([-._a-z0-9]+)\\/(${issueTypes})\\/(\\d+)`, 'gmi');
const markdownRegex = new RegExp(`(${keyPhrases}) \\[.*\\]\\(https?:\\/\\/(?:${domainsString})\\/([-_\\w]+)\\/([-._a-z0-9]+)\\/(${issueTypes})\\/(\\d+)\\)`, 'gmi');

function escapeDomainForRegex(domain) {
return domain.replace('.', '\\.');
}

function combineDomains(domains) {
return domains.map(x => escapeDomainForRegex(x)).join("|");
}

function extractFromMatch(match) {
return {
Expand Down

0 comments on commit e1985f2

Please sign in to comment.