Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Github actions to automate some tedious tasks. #4414

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 20 additions & 0 deletions .github/workflows/close_stale_issues.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
name: Close inactive issues
on:
schedule:
- cron: "30 1 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest
permissions:
issues: write
pull-requests: write
steps:
- uses: actions/stale@v5
with:
days-before-issue-stale: 30
stale-issue-label: "stale"
stale-issue-message: "This issue is stale because it has been open for 30 days with no activity."
days-before-pr-stale: -1
days-before-pr-close: -1
repo-token: ${{ secrets.GITHUB_TOKEN }}
24 changes: 24 additions & 0 deletions .github/workflows/draft_without_issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: Convert PRs to Drafts without Linked Issue

on:
pull_request:
types:
- opened

jobs:
checkLinkedIssue:
runs-on: ubuntu-latest
steps:
- name: Check if PR has a linked issue
id: check_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const prPayload = context.payload.pull_request;
if (!prPayload.issue_url) {
const octokit = context.github;
const updatePayload = context.issue({ draft: true });
await octokit.pulls.update(updatePayload);
core.setFailed('Pull request converted to draft as it does not have a linked issue.');
}
32 changes: 32 additions & 0 deletions .github/workflows/enforce_point_label.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
name: Enforce Point Label on In-Progress Issues

on:
issues:
types:
- labeled
- unlabeled

jobs:
checkPointLabel:
runs-on: ubuntu-latest
steps:
- name: Check issue status and label
id: check_issue
uses: actions/github-script@v4
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issuePayload = context.payload.issue;
const issueLabels = issuePayload.labels;
const issueBody = issuePayload.body.toLowerCase();

const isInProgress = issueBody.includes('In Progress');

const labelRegex = /^\d+$/; // Matches only numbers

if (issueStatus === 'open' && isInProgress && !issueLabels.find(label => labelRegex.test(label.name))) {
const octokit = context.github;
const addLabelPayload = context.issue({ labels: ['point'] });
await octokit.issues.addLabels(addLabelPayload);
core.setFailed('The "point" label is required for issues in progress.');
}
36 changes: 36 additions & 0 deletions .github/workflows/move_to_boom.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Close Ticket on Boom

on:
project_card:
types:
- moved

jobs:
closeTicket:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Close Ticket
if: contains(github.event.project_card.column_name == 'Boom')
run: |
# Extract the ticket number from the project card's content URL
TICKET_NUMBER=$(echo "${{ github.event.project_card.content_url }}" | awk -F'/' '{print $NF}')

# Close the corresponding issue
echo "::set-env name=TICKET_NUMBER::$TICKET_NUMBER" # Set the ticket number as an environment variable
echo "::set-output name=ISSUE_NUMBER::$TICKET_NUMBER" # Set the issue number as an output for later steps

- name: Set Issue Number
id: issue_number
run: echo "::set-output name=ISSUE_NUMBER::$TICKET_NUMBER"

- name: Close Issue
if: steps.closeTicket.outputs.ISSUE_NUMBER != ''
uses: peter-evans/close-issue@v1
with:
issue-number: ${{ steps.issue_number.outputs.ISSUE_NUMBER }}
comment: 'This issue was closed because the corresponding item was moved to the "boom" column.'
delete-branch: false