Skip to content
This repository was archived by the owner on Sep 5, 2025. It is now read-only.
Open
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
1 change: 1 addition & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -19,3 +19,4 @@ deployments/.env
#ignore docker compose file
deployments/docker-compose.yaml
.DS_Store
.env
49 changes: 49 additions & 0 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
name: Release

on:
workflow_dispatch:

jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: Login to GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
username: $GITHUB_ACTOR
password: "${{ secrets.GITHUB_TOKEN }}"
- name: Generate a container image
run: |
version=$(cat VERSION)
docker build . -t ghcr.io/${USERNAME_OR_ORG}/github-updates:${version}
docker push ghcr.io/${USERNAME_OR_ORG}/github-updates:${version}
shell: bash
env:
USERNAME_OR_ORG: "${{ github.repository_owner }}"
- name: Increment the pom version
run: |
current_version=$(cat VERSION)
if [[ "$current_version" =~ v([0-9]+)\.([0-9]+) ]]; then
major="${BASH_REMATCH[1]}"
minor="${BASH_REMATCH[2]}"
else
echo "Invalid version format. Expected format: v<major>.<minor>"
exit 1
fi
minor=$((minor + 1))
new_version="v${major}.${minor}"
echo "$new_version" > VERSION
shell: bash
- name: Create Pull Request with new PRs
uses: peter-evans/create-pull-request@v3
with:
token: "${{ secrets.GITHUB_TOKEN }}"
branch-suffix: timestamp
title: Increment version after release
labels: auto-version-increment
signoff: true
delete-branch: false
commit-message: Auto increment version after release
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,4 @@ assets/generated-data/*.json
# Ignore .env file
deployments/.env
.DS_Store
.env
1 change: 0 additions & 1 deletion Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ RUN make

WORKDIR /appbin
RUN cp /app/github-updates /appbin/
RUN rm -r /app

ENV PATH=${PATH}:/appbin

Expand Down
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@ global:
name: "Hyperledger Labs"
github: "hyperledger-labs"
scrape-duration-days: 7
max-records: 0 # to list everything, otherwise consider the maximum number of records in the summary
# Set this to true and specify input/output files
external-template:
enabled: false
Expand Down
42 changes: 32 additions & 10 deletions cmd/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@ func main() {
generateExternalPR(
config.PullRequests.PRExternalTemplate,
externalPRList,
config.GlobalConfiguration.MaxRecords,
)
if err != nil {
log.Fatalf("Failed to generate the report: %v, with template: %v. Error is: %v",
Expand Down Expand Up @@ -107,6 +108,7 @@ func main() {
generateExternalRelease(
config.Releases.ReleaseExternalTemplate,
externalReleaseList,
config.GlobalConfiguration.MaxRecords,
)
if err != nil {
log.Fatalf("Failed to generate the report: %v, with template: %v. Error is: %v",
Expand Down Expand Up @@ -136,6 +138,7 @@ func main() {
generateExternalIssue(
config.Issues.IssueExternalTemplate,
externalIssueList,
config.GlobalConfiguration.MaxRecords,
)
if err != nil {
log.Fatalf("Failed to generate the report: %v, with template: %v. Error is: %v",
Expand Down Expand Up @@ -237,6 +240,7 @@ func getExternalReports(config configs.Configuration,
func generateExternalPR(
externalTemplate configs.ElementExternalTemplate,
values []configs.ExternalPRDetails,
maxRecords int,
) error {
if len(values) == 0 {
log.Println("External template file generation is not requested")
Expand All @@ -256,12 +260,13 @@ func generateExternalPR(
}

// store the trending info in summary file
return generateTopFile(recentPRs(values), externalTemplate)
return generateTopFile(recentPRs(values, maxRecords), externalTemplate)
}

func generateExternalIssue(
externalTemplate configs.ElementExternalTemplate,
values []configs.ExternalIssueDetails,
maxRecords int,
) error {
if len(values) == 0 {
log.Println("External template file generation is not requested")
Expand All @@ -281,12 +286,13 @@ func generateExternalIssue(
}

// store the trending info in summary file
return generateTopFile(recentIssues(values), externalTemplate)
return generateTopFile(recentIssues(values, maxRecords), externalTemplate)
}

func generateExternalRelease(
externalTemplate configs.ElementExternalTemplate,
values []configs.ExternalReleaseDetails,
maxRecords int,
) error {
if len(values) == 0 {
log.Println("External template file generation is not requested")
Expand All @@ -306,7 +312,7 @@ func generateExternalRelease(
}

// store the trending info in summary file
return generateTopFile(recentReleases(values), externalTemplate)
return generateTopFile(recentReleases(values, maxRecords), externalTemplate)
}

func generateExternalFile(
Expand All @@ -318,7 +324,7 @@ func generateExternalFile(
var err error
outputFileName := filename + filepath.Ext(externalTemplate.Input)
outputPath := path.Join(externalTemplate.Output, org)
err = os.MkdirAll(outputPath, 755)
err = os.MkdirAll(outputPath, 0755)
if err != nil {
return err
}
Expand Down Expand Up @@ -482,7 +488,7 @@ func getExpectedPullRequests(
return expectedPrs, false
}

func recentPRs(prs []configs.ExternalPRDetails) []github.PullRequest {
func recentPRs(prs []configs.ExternalPRDetails, maxRecords int) []github.PullRequest {
// get the list of all PRs from across repositories
var allPRs []github.PullRequest
for _, pr := range prs {
Expand All @@ -496,10 +502,13 @@ func recentPRs(prs []configs.ExternalPRDetails) []github.PullRequest {

// return the top n items
// n is 5 for now
return allPRs[:5]
if maxRecords == 0 {
return allPRs
}
return allPRs[:min(len(allPRs), 5)]
}

func recentIssues(issues []configs.ExternalIssueDetails) []github.Issue {
func recentIssues(issues []configs.ExternalIssueDetails, maxRecords int) []github.Issue {
// get the list of all PRs from across repositories
var allIssues []github.Issue
for _, issue := range issues {
Expand All @@ -513,10 +522,13 @@ func recentIssues(issues []configs.ExternalIssueDetails) []github.Issue {

// return the top n items
// n is 5 for now
return allIssues[:5]
if maxRecords == 0 {
return allIssues
}
return allIssues[:min(len(allIssues), 5)]
}

func recentReleases(releases []configs.ExternalReleaseDetails) []github.RepositoryRelease {
func recentReleases(releases []configs.ExternalReleaseDetails, maxRecords int) []github.RepositoryRelease {
// get the list of all PRs from across repositories
var allReleases []github.RepositoryRelease
for _, release := range releases {
Expand All @@ -530,5 +542,15 @@ func recentReleases(releases []configs.ExternalReleaseDetails) []github.Reposito

// return the top n items
// n is 5 for now
return allReleases[:5]
if maxRecords == 0 {
return allReleases
}
return allReleases[:min(len(allReleases), maxRecords)]
}

func min(a, b int) int {
if a < b {
return a
}
return b
}
19 changes: 11 additions & 8 deletions internal/pkg/client/ghclient.go
Original file line number Diff line number Diff line change
Expand Up @@ -249,13 +249,15 @@ func (c Client) IssueWithLabels(org string, repos []string, issueLabels []string
}
for _, issue := range issues {

publishedDate := issue.GetCreatedAt()
startDate := time.Now().AddDate(0, 0, dayDiff)
log.Println("publishedDate", publishedDate, "start date", startDate, " if condition", publishedDate.Before(startDate))

if publishedDate.Before(startDate) {
issueDateReached = true
break
if dayDiff != 0 {
publishedDate := issue.GetCreatedAt()
startDate := time.Now().AddDate(0, 0, dayDiff)
log.Println("publishedDate", publishedDate, "start date", startDate, " if condition", publishedDate.Before(startDate))

if publishedDate.Before(startDate) {
issueDateReached = true
break
}
}

//check if the issue contains the desired labels or not
Expand Down Expand Up @@ -287,7 +289,8 @@ func (c Client) IssueWithLabels(org string, repos []string, issueLabels []string
return issueList, nil
}

/**
/*
*
Utility function to check if the issue contains at least one of the desired labels
*/
func doesIssueContainLabels(issue *github.Issue, allowedLabels []string) bool {
Expand Down
1 change: 1 addition & 0 deletions internal/pkg/configs/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ type ElementExternalTemplate struct {
type GlobalConfiguration struct {
Organizations []Organization `yaml:"organizations"`
DaysCount int `yaml:"scrape-duration-days"`
MaxRecords int `yaml:"max-records"`
ExternalTemplate ExternalTemplate `yaml:"external-template"`
RepoClass string `yaml:"scrape-repo-class"`
}
Expand Down