Repository: release-drafter/release-drafter
Pull request #775 (2021-02-04 06:52:43)

Bump node from 15.5.1-alpine to 15.8.0-alpine
Bumps node from 15.5.1-alpine to 15.8.0-alpine.


[![Dependabot compatibility score](https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=node&package-manager=docker&previous-version=15.5.1-alpine&new-version=15.8.0-alpine)](https://docs.github.com/en/github/managing-security-vulnerabilities/about-dependabot-security-updates#about-compatibility-scores)

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting `@dependabot rebase`.

[//]: # (dependabot-automerge-start)
[//]: # (dependabot-automerge-end)

---

<details>
<summary>Dependabot commands and options</summary>
<br />

You can trigger Dependabot actions by commenting on this PR:
- `@dependabot rebase` will rebase this PR
- `@dependabot recreate` will recreate this PR, overwriting any edits that have been made to it
- `@dependabot merge` will merge this PR after your CI passes on it
- `@dependabot squash and merge` will squash and merge this PR after your CI passes on it
- `@dependabot cancel merge` will cancel a previously requested merge and block automerging
- `@dependabot reopen` will reopen this PR if it is closed
- `@dependabot close` will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
- `@dependabot ignore this major version` will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this minor version` will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
- `@dependabot ignore this dependency` will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)


</details>


Patch:
diff --git a/Dockerfile b/Dockerfile
index 7b6e4e3..4bac089 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,4 +1,4 @@
-FROM node:15.5.1-alpine@sha256:7d8fcef4cc84dafe2f4fbcbcd58ee704d452f1e49bc3393c9452992713808dbc
+FROM node:15.8.0-alpine@sha256:57551777043949b752e47a2968f1142b5865adb9b01ea0b28a6120eea45f109e
 ARG NODE_ENV=production
 ENV NODE_ENV=${NODE_ENV}
 LABEL "repository"="https://github.com/toolmantim/release-drafter"
diff --git a/README.md b/README.md
index 4e785ab..ca20c32 100644
--- a/README.md
+++ b/README.md
@@ -113,6 +113,7 @@ You can configure Release Drafter using the following key in your `.github/relea
 | `prerelease`           | Optional | Mark the draft release as pre-release. Default `false`.                                                                                                                    |
 | `version-resolver`     | Optional | Adjust the `$RESOLVED_VERSION` variable using labels. Refer to [Version Resolver](#version-resolver) to learn more about this                                              |
 | `filter-by-commitish`  | Optional | Filter previous releases to consider only the target branch of the release. Default: `false`.                                                                              |
+| `commitish`            | Optional | Specify the target branch of the release. Default: the default branch of the repo.                                                                                         |
 
 Release Drafter also supports [Probot Config](https://github.com/probot/probot-config), if you want to store your configuration files in a central repository. This allows you to share configurations between projects, and create a organization-wide configuration file by creating a repository named `.github` with the file `.github/release-drafter.yml`.
 
@@ -277,6 +278,7 @@ The Release Drafter GitHub Action accepts a number of optional inputs directly i
 | `version`     | The version to be associated with the GitHub release that's created or updated. This will override any version calculated by the release-drafter.                                                                                                                                                                                                                  |
 | `publish`     | A boolean indicating whether the release being created or updated should be immediately published. This may be useful if the output of a previous workflow step determines that a new version of your project has been (or will be) released, as with [`salsify/action-detect-and-tag-new-version`](https://github.com/salsify/action-detect-and-tag-new-version). |
 | `prerelease`  | A boolean indicating whether the relase being created or updated is a prerelease.                                                                                                                                                                                                                                                                                  |
+| `commitish`   | A string specifying the target branch for the release being created.                                                                                                                                                                                                                                                                                               |
 
 ## Action Outputs
 
diff --git a/action.yml b/action.yml
index 61cd89c..ef5234a 100644
--- a/action.yml
+++ b/action.yml
@@ -38,6 +38,11 @@ inputs:
       A boolean indicating whether the relase 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: ''
 outputs:
   id:
     description: The ID of therelease that was created or updated.
diff --git a/dist/index.js b/dist/index.js
index 1ce6147..776c348 100644
--- a/dist/index.js
+++ b/dist/index.js
@@ -410,6 +410,7 @@ const DEFAULT_CONFIG = Object.freeze({
   'sort-direction': SORT_DIRECTIONS.descending,
   prerelease: false,
   'filter-by-commitish': false,
+  commitish: '',
   'category-template': `## $TITLE`,
 })
 
@@ -799,10 +800,13 @@ module.exports.generateReleaseInfo = ({
       : ''
   }
 
+  let commitish = config['commitish'] || ''
+
   return {
     name,
     tag,
     body,
+    commitish,
     prerelease: isPreRelease,
     draft: shouldDraft,
   }
@@ -811,6 +815,7 @@ module.exports.generateReleaseInfo = ({
 module.exports.createRelease = ({ context, releaseInfo }) => {
   return context.octokit.repos.createRelease(
     context.repo({
+      target_commitish: releaseInfo.commitish,
       name: releaseInfo.name,
       tag_name: releaseInfo.tag,
       body: releaseInfo.body,
@@ -919,6 +924,8 @@ const schema = (context) => {
         DEFAULT_CONFIG['filter-by-commitish']
       ),
 
+      commitish: Joi.string().allow('').default(DEFAULT_CONFIG['commitish']),
+
       replacers: Joi.array()
         .items(
           Joi.object().keys({
diff --git a/lib/default-config.js b/lib/default-config.js
index ce925ae..c81f6d7 100644
--- a/lib/default-config.js
+++ b/lib/default-config.js
@@ -21,6 +21,7 @@ const DEFAULT_CONFIG = Object.freeze({
   'sort-direction': SORT_DIRECTIONS.descending,
   prerelease: false,
   'filter-by-commitish': false,
+  commitish: '',
   'category-template': `## $TITLE`,
 })
 
diff --git a/lib/releases.js b/lib/releases.js
index 7bb83a4..fe4c73c 100644
--- a/lib/releases.js
+++ b/lib/releases.js
@@ -290,10 +290,13 @@ module.exports.generateReleaseInfo = ({
       : ''
   }
 
+  let commitish = config['commitish'] || ''
+
   return {
     name,
     tag,
     body,
+    commitish,
     prerelease: isPreRelease,
     draft: shouldDraft,
   }
@@ -302,6 +305,7 @@ module.exports.generateReleaseInfo = ({
 module.exports.createRelease = ({ context, releaseInfo }) => {
   return context.octokit.repos.createRelease(
     context.repo({
+      target_commitish: releaseInfo.commitish,
       name: releaseInfo.name,
       tag_name: releaseInfo.tag,
       body: releaseInfo.body,
diff --git a/lib/schema.js b/lib/schema.js
index 25475bf..fd1b4a3 100644
--- a/lib/schema.js
+++ b/lib/schema.js
@@ -60,6 +60,8 @@ const schema = (context) => {
         DEFAULT_CONFIG['filter-by-commitish']
       ),
 
+      commitish: Joi.string().allow('').default(DEFAULT_CONFIG['commitish']),
+
       replacers: Joi.array()
         .items(
           Joi.object().keys({


Test patch:
diff --git a/test/fixtures/config/config-with-commitish.yml b/test/fixtures/config/config-with-commitish.yml
new file mode 100644
index 0000000..a71736c
--- /dev/null
+++ b/test/fixtures/config/config-with-commitish.yml
@@ -0,0 +1,2 @@
+commitish: 'staging'
+template: 'dummy'
diff --git a/test/index.test.js b/test/index.test.js
index 2530af6..6f40aa2 100644
--- a/test/index.test.js
+++ b/test/index.test.js
@@ -144,6 +144,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -213,6 +214,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -266,6 +268,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -325,6 +328,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -383,6 +387,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -429,6 +434,7 @@ describe('release-drafter', () => {
                   "name": "v2.0.1 (Code name: Placeholder)",
                   "prerelease": false,
                   "tag_name": "v2.0.1",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -478,6 +484,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -528,6 +535,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -578,6 +586,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -624,6 +633,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -680,6 +690,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -721,6 +732,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -832,6 +844,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -888,6 +901,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -944,6 +958,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1004,6 +1019,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1061,6 +1077,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1112,6 +1129,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1157,6 +1175,7 @@ describe('release-drafter', () => {
                   "name": "v2.0.1 (Code name: Placeholder)",
                   "prerelease": false,
                   "tag_name": "v2.0.1",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1200,6 +1219,7 @@ describe('release-drafter', () => {
                   "name": "v2.1 (Code name: Placeholder)",
                   "prerelease": false,
                   "tag_name": "v2.1",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1243,6 +1263,7 @@ describe('release-drafter', () => {
                   "name": "v3 (Code name: Placeholder)",
                   "prerelease": false,
                   "tag_name": "v3",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1297,6 +1318,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -1352,6 +1374,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -1407,6 +1430,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -1459,6 +1483,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -1513,6 +1538,7 @@ describe('release-drafter', () => {
                     "name": "",
                     "prerelease": false,
                     "tag_name": "",
+                    "target_commitish": "",
                   }
                 `)
                 return true
@@ -1579,6 +1605,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1634,6 +1661,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -1702,6 +1730,7 @@ describe('release-drafter', () => {
                 "name": "",
                 "prerelease": false,
                 "tag_name": "",
+                "target_commitish": "",
               }
             `)
             return true
@@ -1769,6 +1798,7 @@ describe('release-drafter', () => {
                 "name": "",
                 "prerelease": false,
                 "tag_name": "",
+                "target_commitish": "",
               }
             `)
             return true
@@ -1866,6 +1896,7 @@ describe('release-drafter', () => {
                 "name": "",
                 "prerelease": false,
                 "tag_name": "",
+                "target_commitish": "",
               }
             `)
             return true
@@ -2179,6 +2210,7 @@ describe('release-drafter', () => {
                   "name": "v1.0.2 🌈",
                   "prerelease": false,
                   "tag_name": "v1.0.2",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2234,6 +2266,7 @@ describe('release-drafter', () => {
                   "name": "v1.0.2 🌈",
                   "prerelease": false,
                   "tag_name": "v1.0.2",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2287,6 +2320,7 @@ describe('release-drafter', () => {
                   "name": "",
                   "prerelease": false,
                   "tag_name": "",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2338,6 +2372,7 @@ describe('release-drafter', () => {
                   "name": "v2.0.1 🌈",
                   "prerelease": false,
                   "tag_name": "v2.0.1",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2384,6 +2419,7 @@ describe('release-drafter', () => {
                   "name": "v2.1.0",
                   "prerelease": false,
                   "tag_name": "v2.1.0",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2427,6 +2463,7 @@ describe('release-drafter', () => {
                   "name": "v2.0.1",
                   "prerelease": false,
                   "tag_name": "v2.0.1",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2470,6 +2507,7 @@ describe('release-drafter', () => {
                   "name": "v2.1.0",
                   "prerelease": false,
                   "tag_name": "v2.1.0",
+                  "target_commitish": "",
                 }
               `)
               return true
@@ -2513,6 +2551,54 @@ describe('release-drafter', () => {
                   "name": "v3.0.0",
                   "prerelease": false,
                   "tag_name": "v3.0.0",
+                  "target_commitish": "",
+                }
+              `)
+              return true
+            }
+          )
+          .reply(200, require('./fixtures/release'))
+
+        await probot.receive({
+          name: 'push',
+          payload: require('./fixtures/push'),
+        })
+
+        expect.assertions(1)
+      })
+    })
+
+    describe('with commitish', () => {
+      it('allows specification of a target commitish', async () => {
+        getConfigMock('config-with-commitish.yml')
+
+        nock('https://api.github.com')
+          .get(
+            '/repos/toolmantim/release-drafter-test-project/releases?per_page=100'
+          )
+          .reply(200, [require('./fixtures/release')])
+
+        nock('https://api.github.com')
+          .post('/graphql', (body) =>
+            body.query.includes('query findCommitsWithAssociatedPullRequests')
+          )
+          .reply(
+            200,
+            require('./fixtures/__generated__/graphql-commits-forking.json')
+          )
+
+        nock('https://api.github.com')
+          .post(
+            '/repos/toolmantim/release-drafter-test-project/releases',
+            (body) => {
+              expect(body).toMatchInlineSnapshot(`
+                Object {
+                  "body": "dummy",
+                  "draft": true,
+                  "name": "",
+                  "prerelease": false,
+                  "tag_name": "",
+                  "target_commitish": "staging",
                 }
               `)
               return true
diff --git a/test/schema.test.js b/test/schema.test.js
index f308d89..d4549a9 100644
--- a/test/schema.test.js
+++ b/test/schema.test.js
@@ -39,6 +39,7 @@ const invalidConfigs = [
     'is required and must be a regexp or a string',
   ],
   [{ replacers: [{ search: '123', replace: 123 }] }, 'must be a string'],
+  [{ commitish: false }, 'must be a string'],
 ]
 
 describe('schema', () => {