Skip to content

Commit

Permalink
Merge branch 'main' into feat-2398
Browse files Browse the repository at this point in the history
  • Loading branch information
thomaspoignant authored Nov 4, 2024
2 parents 71b946e + e5026ab commit 02accdc
Show file tree
Hide file tree
Showing 347 changed files with 22,112 additions and 2,577 deletions.
127 changes: 118 additions & 9 deletions .github/workflows/unassign-issue.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
name: Unassign Issues
name: Assign and Unassign Issues

on:
schedule:
Expand All @@ -7,14 +7,123 @@ on:
types: [created]
workflow_dispatch:


env:
DAYS_UNTIL_STALE: 20 # Number of days before marking as stale
ASSIGNED_LABEL: "📍 Assigned"
PINNED_LABEL: "📌 Pinned"
STALE_LABEL: "Stale"

jobs:
assign:
assign_issue:
if: github.event_name == 'issue_comment'
runs-on: ubuntu-latest
steps:
- name: Assign the user or unassign stale assignments
uses: takanome-dev/[email protected]
with:
github_token: '${{ secrets.GITHUB_TOKEN }}'
assigned_label: 📍 Assigned
days_until_unassign: 10
pin_label: 📌 Pinned
- name: Check for /assign-me comment
uses: actions/github-script@v7
with:
script: |
const { owner, repo } = context.repo;
const issue_number = context.issue.number;
const comment = context.payload.comment.body;
const totalDays = process.env.DAYS_UNTIL_STALE;
const assignedLabel = process.env.ASSIGNED_LABEL;
const pinnedLabel = process.env.PINNED_LABEL;
async function addComment(body) {
await github.rest.issues.createComment({ owner, repo, issue_number, body });
}
async function addLabels(labels) {
await github.rest.issues.addLabels({ owner, repo, issue_number, labels });
}
if (comment.includes('/assign-me')) {
try {
// Get the current issue details
const issue = await github.rest.issues.get({ owner, repo, issue_number });
if (issue.data.assignees.length === 0) {
// Issue is not assigned, proceed with assignment
await github.rest.issues.addAssignees({ owner, repo, issue_number, assignees: [context.actor] });
// Add the '📍 Assigned' label to the issue
await addLabels([assignedLabel]);
// Add the custom comment to notify the user of the assignment
const successMessage = `👋 Hey @${context.actor}, thanks for your interest in this issue! 🎉\n\n`
+ `⚠ Note that this issue will become unassigned if it isn't closed within **${totalDays} days**.\n\n`
+ `🔧 A maintainer can also add the **${pinnedLabel}** label to prevent it from being unassigned automatically.`;
await addComment(successMessage);
console.log(`Assigned issue #${issue_number} to ${context.actor}`);
} else {
// Issue is already assigned
const currentAssignee = issue.data.assignees[0].login;
const alreadyAssignedMessage = `👋 Hey @${context.actor}, this issue is already assigned to @${currentAssignee}.\n\n`
+ `⚠️ It will become unassigned if it isn't closed within **${totalDays} days**.\n\n`
+ `🔧 A maintainer can also add you to the list of assignees or swap you with the current assignee.`;
await addComment(alreadyAssignedMessage);
console.log(`Failed to assign issue #${issue_number} to ${context.actor} as it's already assigned to ${currentAssignee}`);
}
} catch (error) {
console.error(`Error assigning issue #${issue_number}: ${error.message}`);
}
}
unassign_stale:
if: github.event_name == 'schedule'
runs-on: ubuntu-latest
steps:
- name: Mark stale issues
uses: actions/stale@v9
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-issue-message: "This issue has been automatically unassigned due to inactivity."
days-before-stale: ${{ env.DAYS_UNTIL_STALE }} # Number of days before marking as stale
days-before-close: -1 # Don't close stale issues
exempt-issue-labels: ${{ env.PINNED_LABEL }}
remove-stale-when-updated: false
include-only-assigned: true

- name: Unassign stale issues and remove labels
uses: actions/github-script@v7
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const { owner, repo } = context.repo;
const assignedLabel = process.env.ASSIGNED_LABEL;
const staleLabel = process.env.STALE_LABEL;
async function removeLabel(issue_number, name) {
try {
await github.rest.issues.removeLabel({ owner, repo, issue_number, name });
} catch (error) {
console.log(`Failed to remove ${name} label from issue #${issue_number}: ${error.message}`);
}
}
const staleIssues = await github.paginate(github.rest.issues.listForRepo, {
owner, repo,
state: 'open',
labels: staleLabel
});
for (const issue of staleIssues) {
try {
// Remove assignees
await github.rest.issues.removeAssignees({
owner, repo, issue_number: issue.number,
assignees: issue.assignees.map(a => a.login)
});
// Remove 'Assigned' and 'Stale' labels
await removeLabel(issue.number, assignedLabel);
await removeLabel(issue.number, staleLabel);
console.log(`Unassigned issue #${issue.number}`);
} catch (error) {
console.error(`Error unassigning issue #${issue.number}: ${error.message}`);
}
}
5 changes: 4 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -42,4 +42,7 @@ go-feature-flag-relay-proxy/
node_modules/
oryxBuildBinary

./.sonarlint
./.sonarlint

# Localstack cache
volume
12 changes: 7 additions & 5 deletions ADOPTERS.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,15 @@

Thank you for trusting the `go-feature-flag` and using it in your organization.

| **Organizartion** | **Website / Contact** | **Description of use** |
|----------------------|-------------------------------------------------------|------------------------------------------------|
| **Organization** | **Website / Contact** | **Description of use** |
| -------------------- | ----------------------------------------------------- | ---------------------------------------------- |
| Cast.ai | https://cast.ai/ | |
| Chapati systems | https://chapati.systems/ | |
| Lyft | https://github.com/lyft/atlantis | Inside the Atlantis fork used by Lyft. |
| Tencent | https://github.com/TencentBlueKing/bkmonitor-datalink | Used inside BKMONITOR-DATALINK. |
| Agentero | https://agentero.com/ | FF tool within Agentero platform |
| Stacklok | https://github.com/stacklok/minder | |
| HelloWorldCS | https://helloworldcs.org | Feature flags for internal tools + app |
| Alternative Payments | https://www.alternativepayments.io | Feature Flagging for frontend and backend apps |
| Minder (OpenSSF) | https://github.com/mindersec/minder | Feature flags using OpenFeature |
| Stacklok | https://github.com/stacklok/ | Feature flags (looking at using relay) |
| HelloWorldCS | https://helloworldcs.org | Feature flags for internal tools + app |
| Alternative Payments | https://www.alternativepayments.io | Feature Flagging for frontend and backend apps |
| Mecena | https://mecena.co | FF for backend microservices |
6 changes: 4 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
<a href="https://github.com/thomaspoignant/go-feature-flag/actions/workflows/ci.yml"><img src="https://github.com/thomaspoignant/go-feature-flag/actions/workflows/ci.yml/badge.svg" alt="Build Status" /></a>
<a href="https://codecov.io/gh/thomaspoignant/go-feature-flag"><img src="https://codecov.io/gh/thomaspoignant/go-feature-flag/branch/main/graph/badge.svg?token=T59ACQWW1H"/></a>
<a href="https://sonarcloud.io/dashboard?id=thomaspoignant_go-feature-flag"><img src="https://sonarcloud.io/api/project_badges/measure?project=thomaspoignant_go-feature-flag&metric=alert_status" alt="Sonarcloud Status" /></a>
<a href="https://github.com/thomaspoignant/go-feature-flag/actions/workflows/codeql-analysis.yml"><img src="https://github.com/thomaspoignant/go-feature-flag/workflows/CodeQL/badge.svg" alt="Build Status" /></a>
<a href="https://goreportcard.com/report/github.com/thomaspoignant/go-feature-flag"><img src="https://goreportcard.com/badge/github.com/thomaspoignant/go-feature-flag" alt="Build Status" /></a>
<a href="https://github.com/thomaspoignant/go-feature-flag/blob/main/LICENSE"><img src="https://img.shields.io/github/license/thomaspoignant/go-feature-flag" alt="License"/></a>
<br/>
<a href="https://github.com/thomaspoignant/go-feature-flag/releases"><img src="https://img.shields.io/github/v/release/thomaspoignant/go-feature-flag" alt="Release version" /></a>
Expand Down Expand Up @@ -545,6 +545,7 @@ A notifier will send one notification to the targeted system to inform them that
Available notifiers are:
- **Slack**
- **Webhook**
- **Discord**

## Export data
**GO Feature Flag** allows you to export data about the usage of your flags.
Expand All @@ -553,6 +554,7 @@ It collects all variation events and can save these events in several locations:
- **Local file** *- create local files with the variation usages.*
- **Log** *- use your logger to write the variation usages.*
- **AWS S3** *- export your variation usages to S3.*
- **AWS Kinesis** *- publish your variation usages to AWS Kinesis Stream.*
- **Google Cloud Storage** *- export your variation usages to Google Cloud Storage.*
- **Webhook** *- export your variation usages by calling a webhook.*
- **AWS SQS** *- export your variation usages by sending events to SQS.*
Expand Down Expand Up @@ -610,7 +612,7 @@ Thanks so much to our contributors.
[Become a sponsor](https://github.com/sponsors/thomaspoignant) and show your support to GO Feature Flag.

These are our really cool sponsors!
<!-- sponsors --><a href="https://github.com/cybozu"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;2433152?v&#x3D;4" width="60px" alt="Cybozu" /></a><!-- sponsors -->
<!-- sponsors --><a href="https://github.com/cybozu"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;2433152?v&#x3D;4" width="60px" alt="Cybozu" /></a><a href="https://github.com/clemsau"><img src="https:&#x2F;&#x2F;avatars.githubusercontent.com&#x2F;u&#x2F;36474372?u&#x3D;792957256f1997cbdad8a6c6e7b60c2db0205a8f&amp;v&#x3D;4" width="60px" alt="Clément Sauvage" /></a><!-- sponsors -->

## Adopters

Expand Down
Loading

0 comments on commit 02accdc

Please sign in to comment.