Skip to content

Commit

Permalink
Configurable functionality (#789)
Browse files Browse the repository at this point in the history
  • Loading branch information
rofafor committed Feb 28, 2021
1 parent ed8b54a commit 30279d4
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 7 deletions.
6 changes: 6 additions & 0 deletions README.md
Expand Up @@ -27,11 +27,17 @@ jobs:
update_release_draft:
runs-on: ubuntu-latest
steps:
# (Optional) GitHub Enterprise requires GHE_HOST variable set
#- name: Set GHE_HOST
# run: |
# echo "GHE_HOST=${GITHUB_SERVER_URL##https:\/\/}" >> $GITHUB_ENV

# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: release-drafter/release-drafter@v5
# (Optional) specify config name to use, relative to .github/. Default: release-drafter.yml
# with:
# config-name: my-config.yml
# disable-autolabeler: true
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
```
Expand Down
12 changes: 11 additions & 1 deletion action.yml
Expand Up @@ -35,14 +35,24 @@ inputs:
default: ''
prerelease:
description: |
A boolean indicating whether the relase being created or updated is a prerelease.
A boolean indicating whether the release being created or updated is a prerelease.
required: false
default: ''
commitish:
description: |
The object that the release should be created to point to.
required: false
default: ''
disable-releaser:
description: |
A boolean indicating whether the releaser mode is disabled.
required: false
default: ''
disable-autolabeler:
description: |
A boolean indicating whether the autolabeler mode is disabled.
required: false
default: ''
outputs:
id:
description: The ID of therelease that was created or updated.
Expand Down
19 changes: 16 additions & 3 deletions dist/index.js
Expand Up @@ -66,12 +66,14 @@ module.exports = (app, { getRouter }) => {
'pull_request.synchronize',
],
async (context) => {
const { disableAutolabeler } = getInput()

const config = await getConfig({
context,
configName: core.getInput('config-name'),
})

if (config === null) return
if (config === null || disableAutolabeler) return

let issue = {
...context.issue({ pull_number: context.payload.pull_request.number }),
Expand Down Expand Up @@ -159,7 +161,14 @@ module.exports = (app, { getRouter }) => {
)

app.on(event, async (context) => {
const { shouldDraft, configName, version, tag, name } = getInput()
const {
shouldDraft,
configName,
version,
tag,
name,
disableReleaser,
} = getInput()

const config = await getConfig({
context,
Expand All @@ -168,7 +177,7 @@ module.exports = (app, { getRouter }) => {

const { isPreRelease } = getInput({ config })

if (config === null) return
if (config === null || disableReleaser) return

// GitHub Actions merge payloads slightly differ, in that their ref points
// to the PR branch instead of refs/heads/master
Expand Down Expand Up @@ -244,6 +253,10 @@ function getInput({ config } = {}) {
version: core.getInput('version') || undefined,
tag: core.getInput('tag') || undefined,
name: core.getInput('name') || undefined,
disableReleaser:
core.getInput('disable-releaser').toLowerCase() === 'true',
disableAutolabeler:
core.getInput('disable-autolabeler').toLowerCase() === 'true',
}
}

Expand Down
19 changes: 16 additions & 3 deletions index.js
Expand Up @@ -29,12 +29,14 @@ module.exports = (app, { getRouter }) => {
'pull_request.synchronize',
],
async (context) => {
const { disableAutolabeler } = getInput()

const config = await getConfig({
context,
configName: core.getInput('config-name'),
})

if (config === null) return
if (config === null || disableAutolabeler) return

let issue = {
...context.issue({ pull_number: context.payload.pull_request.number }),
Expand Down Expand Up @@ -122,7 +124,14 @@ module.exports = (app, { getRouter }) => {
)

app.on(event, async (context) => {
const { shouldDraft, configName, version, tag, name } = getInput()
const {
shouldDraft,
configName,
version,
tag,
name,
disableReleaser,
} = getInput()

const config = await getConfig({
context,
Expand All @@ -131,7 +140,7 @@ module.exports = (app, { getRouter }) => {

const { isPreRelease } = getInput({ config })

if (config === null) return
if (config === null || disableReleaser) return

// GitHub Actions merge payloads slightly differ, in that their ref points
// to the PR branch instead of refs/heads/master
Expand Down Expand Up @@ -207,6 +216,10 @@ function getInput({ config } = {}) {
version: core.getInput('version') || undefined,
tag: core.getInput('tag') || undefined,
name: core.getInput('name') || undefined,
disableReleaser:
core.getInput('disable-releaser').toLowerCase() === 'true',
disableAutolabeler:
core.getInput('disable-autolabeler').toLowerCase() === 'true',
}
}

Expand Down

0 comments on commit 30279d4

Please sign in to comment.