1
0
mirror of https://github.com/lensapp/lens.git synced 2025-05-20 05:10:56 +00:00

Add action to require milestones on PRs

Signed-off-by: Sebastian Malton <sebastian@malton.name>
This commit is contained in:
Sebastian Malton 2021-12-10 09:30:11 -05:00
parent 6284bd1eb4
commit 0a792443af
6 changed files with 1460 additions and 0 deletions

View File

@ -0,0 +1,11 @@
# Container image that runs your code
FROM node:14-alpine
COPY package*.json /home/action/
COPY entrypoint.js /home/action/entrypoint.js
WORKDIR /home/action
RUN npm ci
# Code file to execute when the docker container starts up (`entrypoint.js`)
ENTRYPOINT ["node", "/home/action/entrypoint.js"]

View File

@ -0,0 +1,9 @@
name: 'require-milestone'
description: 'A GitHub Action to require a milestone is placed on a PR to merge it'
author: 'Sebastian Malton'
branding:
icon: 'command'
color: 'blue'
runs:
using: 'docker'
image: 'Dockerfile'

View File

@ -0,0 +1,34 @@
/**
* Copyright (c) 2021 OpenLens Authors
*
* Permission is hereby granted, free of charge, to any person obtaining a copy of
* this software and associated documentation files (the "Software"), to deal in
* the Software without restriction, including without limitation the rights to
* use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
* the Software, and to permit persons to whom the Software is furnished to do so,
* subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
* FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
* COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
* IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
* CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
*/
const { Toolkit } = require("actions-toolkit");
Toolkit.run(async tools => {
if (!tools.context.payload.pull_request.milestone) {
tools.exit.failure(
[
"Milestone error. All PRs must have a milestone set to be merged.",
"Bug fixes can be targeted at the next patch milestone after the feature they fix is targetted.",
"All other PRs should be targetted at the next minor milestone."
].join("\n\n"),
);
}
});

1380
.github/actions/require-milestone/package-lock.json generated vendored Normal file

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,14 @@
{
"name": "require-milestone",
"version": "1.0.0",
"description": "A GitHub action to require that PRs have milestones set before being merged",
"main": "entrypoint.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1"
},
"author": "",
"license": "MIT",
"dependencies": {
"actions-toolkit": "^6.0.1"
}
}

12
.github/workflows/require-milestone.yml vendored Normal file
View File

@ -0,0 +1,12 @@
name: Require Milestone
on:
pull_request:
types: [opened, edited]
jobs:
require_milestone:
runs-on: ubuntu-latest
steps:
# Drafts your next Release notes as Pull Requests are merged into "master"
- uses: ./.github/actions/require-milestone