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

chore(CI): automatically create and assign Milestones #4400

Merged
merged 3 commits into from
Jun 24, 2024
Merged
Show file tree
Hide file tree
Changes from 2 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
55 changes: 55 additions & 0 deletions .github/workflows/ASSIGN_MILESTONE.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
name: Assign Milestones

on:
issues:
types: ['closed']
pull_request:
types: ['closed']

jobs:
assignMilestone:
runs-on: ubuntu-latest
name: Assign Milestone
steps:
- name: Get current Milestone
id: getMilestone
env:
GH_TOKEN: ${{ github.token }}
run: |
# Fetch the list of milestones for the repository
# Filter for milestones that start with 'M' and are open
MILESTONE=$(gh api -H "Accept: application/vnd.github.v3+json" \
/repos/${{ github.repository }}/milestones \
--jq '.[] | select(.title | startswith("M")) | .number'
)

echo "MILESTONE_NUMBER=$MILESTONE" >> $GITHUB_OUTPUT
- name: Assign Issue
if: |
github.event.issue &&
github.event.issue.state_reason != 'not_planned' &&
barmac marked this conversation as resolved.
Show resolved Hide resolved
github.event.issue.milestone == null
env:
MILESTONE_NUMBER: ${{steps.getMilestone.outputs.MILESTONE_NUMBER}}
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{github.event.issue.number}} \
-F "milestone=$MILESTONE_NUMBER"

- name: Assign PR
if: |
github.event.pull_request &&
github.event.pull_request.merged_at &&
github.event.pull_request.milestone == null
env:
MILESTONE_NUMBER: ${{steps.getMilestone.outputs.MILESTONE_NUMBER}}
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{github.event.pull_request.number}} \
-F "milestone=$MILESTONE_NUMBER"
44 changes: 44 additions & 0 deletions .github/workflows/RELEASE_ISSUE.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,50 @@ jobs:
template-path: 'docs/.project/RELEASE_TEMPLATE.md'
package-path: 'app/package.json'

createMilestone:
needs: createReleaseIssue
if: github.event.issue.milestone
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Shouldn't this be enclosed in ${{ }}?

Copy link
Member Author

@marstamm marstamm Jun 24, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For if clauses, using the expression syntax is optional (cf. https://docs.github.com/en/actions/learn-github-actions/expressions).
We can use the syntax for consistency. I think it looks cleaner without it, especially for multi-line conditions

runs-on: ubuntu-latest
name: Create new Milestones
steps:
- name: Close old Milestone
env:
GH_TOKEN: ${{ github.token }}
run: |
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/milestones/${{ github.event.issue.milestone.number }} \
-f "state=closed"
- name: Create and Assign new Milestone
env:
GH_TOKEN: ${{ github.token }}
TITLE: ${{github.event.issue.milestone.title}}
run: |
# Generate new Milestone Title (M<number+1>)
MILESTONE_NUMBER=${TITLE:1}
INCREMENTED_NUMBER=$((MILESTONE_NUMBER + 1))
MILESTONE_NAME=M$INCREMENTED_NUMBER

# Create new Milestone
echo "Creating Milestone" $MILESTONE_NAME
NEW_MILESTONE_NUMBER=$(gh api \
--method POST \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/milestones \
-f "title=$MILESTONE_NAME" -f "state=open" \
--jq '.number'
)
echo "Created Milestone" $NEW_MILESTONE_NUMBER

# Assign new Milestone to new issue
echo "Assigning Milestone to release issue"
gh api \
--method PATCH \
-H "Accept: application/vnd.github+json" \
/repos/${{ github.repository }}/issues/${{ fromJson(needs.createReleaseIssue.outputs.issue).number }} \
-F "milestone=$MILESTONE_NUMBER"

updateSlackRole:
runs-on: ubuntu-latest
if: |
Expand Down
1 change: 0 additions & 1 deletion docs/.project/RELEASE_TEMPLATE.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,4 +68,3 @@ _To be done once release is publicly announced on release day._
* [ ] publish release via update server (push to `live`)
* [ ] announce the release via the Camunda internal [#c8-release-announcements](https://camunda.slack.com/archives/C03NFMH4KC6) channel
* [ ] communicate closed support related issues to [#ask-support](https://camunda.slack.com/archives/CHAC0L80M)
* [ ] close [current milestone](https://github.com/camunda/camunda-modeler/milestones)