Skip to content

Commit

Permalink
chore: automate pr default (#1014)
Browse files Browse the repository at this point in the history
  • Loading branch information
lechnerc77 authored Feb 3, 2025
1 parent e815df3 commit 3a9d6c8
Show file tree
Hide file tree
Showing 3 changed files with 65 additions and 23 deletions.
26 changes: 8 additions & 18 deletions .github/PULL_REQUEST_TEMPLATE.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Purpose
<!-- Describe the intention of the changes being proposed. What problem does it solve or functionality does it add? -->
* ...
- ...

## Does this introduce a breaking change?
<!-- Mark one with an "x". -->
Expand All @@ -23,26 +23,17 @@ What kind of change does this Pull Request introduce?

## How to Test

* Test the code via automated test
- Test the code via automated test

```bash
go test ./...
```

<!-- Add additional steps if applicable -->
* Additional test steps

```
...
make test
```

## What to Check

Verify that the following are valid:

* Automated tests are executed successfully
<!-- Add additional conditions if applicable -->
* ...
- Automated tests are executed successfully

## Other Information
<!-- Add any other helpful information that may be needed here. -->
Expand All @@ -52,8 +43,7 @@ Verify that the following are valid:
<!-- This checklist needs to completed by the reviewer of the PR -->
The following organizational tasks must be completed before merging this PR:

* [ ] The PR is assigned to the Terraform project and a status is set (typically "in review").
* [ ] The PR has the matching labels assigned to it.
* [ ] The PR has a milestone assigned to it.
* [ ] If the PR closes an issue, the issue is referenced.
* [ ] Possible follow-up items are created and linked.
- [ ] The PR status on the Project board is set (typically "in review").
- [ ] The PR has the matching labels assigned to it.
- [ ] If the PR closes an issue, the issue is referenced.
- [ ] Possible follow-up issues are created and linked.
Original file line number Diff line number Diff line change
@@ -1,13 +1,10 @@
# Automatically assign a issue/PR to the central Terraform project
name: Add issues and PRs to central Project Board
# Automatically assign a issue to the central Terraform project
name: Add issues to central Project Board

on:
issues:
types:
- opened
pull_request:
types:
- opened

jobs:
add-to-project:
Expand Down
55 changes: 55 additions & 0 deletions .github/workflows/set-default-values-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@

name: Set default values to PR
# Add the PR to the central project (status in project is set via workflow in project)
# Add the creator of the PR as assignee
# Add the next available milestone to the PR

on:
pull_request:
types:
- opened

permissions:
issues: write
pull-requests: write

jobs:
set-default-values:
runs-on: ubuntu-latest
steps:
- name: Add PR to default project
uses: actions/[email protected]
with:
project-url: https://github.com/orgs/SAP/projects/72
github-token: ${{ secrets.ADD_TO_PROJECT_PAT }}

- name: Add creator as assignee
if: ${{ github.actor != 'dependabot[bot]' }}
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
-H "X-GitHub-Api-Version: 2022-11-28" \
/repos/${{github.repository}}/issues/${{github.event.number}}/assignees \
-f "assignees[]=${{github.actor}}"
- name: Add next milestone
uses: actions/github-script@v7
with:
script: |
const milestones = await github.rest.issues.listMilestones({
owner: context.repo.owner,
repo: context.repo.repo,
state: "open",
sort: "due_on",
direction: "asc"
})
await github.rest.issues.update({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: context.issue.number,
milestone: milestones.data[0].number
});

0 comments on commit 3a9d6c8

Please sign in to comment.