Skip to content

Commit aa87c02

Browse files
committed
Update structure
1 parent 9a23c29 commit aa87c02

File tree

14 files changed

+459
-156
lines changed

14 files changed

+459
-156
lines changed

.github/FUNDING.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
github: [SegoCode]
1+
github: [{username}]
22
community_bridge: # Replace with a single Community Bridge project-name e.g., cloud-foundry
33
issuehunt: # Replace with a single IssueHunt username
44
ko_fi: # Replace with a single ko_fi username

.github/ISSUE_TEMPLATE/bug_report.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ body:
5757
attributes:
5858
label: Confirmation
5959
options:
60-
- label: I performed a [search of the issue tracker](https://github.com/SegoCode/webdl/issues) to avoid opening a duplicate issue
60+
- label: I performed a [search of the issue tracker](https://github.com/{username}/{reponame}/issues) to avoid opening a duplicate issue
6161
required: true
6262
- label: I understand that not filling out this template correctly may lead to the issue being closed
6363
required: true

.github/ISSUE_TEMPLATE/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
blank_issues_enabled: false
22
contact_links:
33
- name: Contact the developer
4-
url: https://SegoCode.github.io/SegoCode/
4+
url: https://{username}.github.io/{username}/
55
about: To discuss any type of related topic

.github/ISSUE_TEMPLATE/feature_request.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ body:
3434
attributes:
3535
label: Confirmation
3636
options:
37-
- label: I performed a [search of the feature requests](https://github.com/SegoCode/webdl/issues) to avoid suggesting a duplicate feature
37+
- label: I performed a [search of the feature requests](https://github.com/{username}/{reponame}/issues) to avoid suggesting a duplicate feature
3838
required: true
3939
- label: I understand that not filling out this template correctly may lead to the request being closed
4040
required: true

.github/SECURITY.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
If you discover a vulnerability in this application, that poses a significant threat to the security of the users, we recommend that you do not open a public issue. Instead, please send your report via [email](https://SegoCode.github.io/SegoCode/). Include as much detailed information as possible to help understand the nature of the vulnerability.
1+
If you discover a vulnerability in this application, that poses a significant threat to the security of the users, we recommend that you do not open a public issue. Instead, please send your report via [email](https://{username}.github.io/{username}/). Include as much detailed information as possible to help understand the nature of the vulnerability.

.github/workflows/do-not-merge.yml

Lines changed: 39 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ on:
55
types: [opened, edited, labeled, unlabeled, synchronize, ready_for_review]
66

77
jobs:
8-
check_wip:
8+
checks:
99
runs-on: ubuntu-latest
1010
steps:
1111
- name: Check if PR is ready to be merged
@@ -24,3 +24,41 @@ jobs:
2424
} else {
2525
console.log('The Pull Request is ready to be merged.');
2626
}
27+
28+
- name: Check if PR is from develop to main
29+
uses: actions/github-script@v6
30+
with:
31+
github-token: ${{ secrets.GITHUB_TOKEN }}
32+
script: |
33+
const pr = context.payload.pull_request;
34+
const baseBranch = pr.base.ref;
35+
const headBranch = pr.head.ref;
36+
37+
if (headBranch === 'develop' && baseBranch === 'main') {
38+
const repoFullName = context.payload.repository.full_name;
39+
const syncWorkflowLink = `https://github.com/${repoFullName}/actions/workflows/sync-from-develop-to-main.yml`;
40+
41+
const message = `
42+
## ⚠️ Direct PR from develop to main detected
43+
44+
This pull request is merging changes directly from \`develop\` to \`main\`.
45+
46+
### Important Note
47+
Please consider using our [sync workflow](${syncWorkflowLink}) instead of this direct PR.
48+
49+
**If you don't use the sync workflow:**
50+
- This PR will not trigger a release
51+
- You'll need to manually handle release processes
52+
`;
53+
54+
await github.rest.issues.createComment({
55+
owner: context.repo.owner,
56+
repo: context.repo.repo,
57+
issue_number: pr.number,
58+
body: message
59+
});
60+
61+
console.log('Added comment to PR from develop to main');
62+
} else {
63+
console.log('PR is not from develop to main, no action needed');
64+
}

.github/workflows/generate-tag.yml

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,9 @@ jobs:
1010
runs-on: ubuntu-latest
1111
steps:
1212
- name: Checkout repository
13-
uses: actions/checkout@v2
13+
uses: actions/checkout@v4
14+
with:
15+
fetch-depth: 0 # Fetch all history for tag retrieval
1416

1517
- name: Set up git
1618
run: |
@@ -66,7 +68,9 @@ jobs:
6668
runs-on: ubuntu-latest
6769
steps:
6870
- name: Checkout repository
69-
uses: actions/checkout@v2
71+
uses: actions/checkout@v4
72+
with:
73+
fetch-depth: 0 # Fetch all history for tag retrieval
7074

7175
- name: Set up git
7276
run: |

.github/workflows/gitleaks.yml

Lines changed: 54 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,67 @@
11
name: Gitleaks
2-
on: [pull_request, workflow_dispatch]
2+
on:
3+
pull_request:
4+
workflow_dispatch:
5+
schedule:
6+
# Run at 00:00 UTC on the first day of each month
7+
- cron: '0 0 1 * *'
8+
39
jobs:
410
scan:
5-
name: gitleaks
11+
name: Gitleaks Scan
612
runs-on: ubuntu-latest
13+
# Only run scheduled jobs on main branch
14+
if: github.event_name != 'schedule' || github.ref == 'refs/heads/main'
715
steps:
816
- name: Checkout code
917
uses: actions/checkout@v4
1018
with:
1119
fetch-depth: 0
20+
1221
- name: Run Gitleaks
22+
id: gitleaks
1323
uses: gitleaks/gitleaks-action@v2
1424
env:
1525
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
26+
continue-on-error: true
27+
28+
- name: Create issue if leaks found
29+
if: steps.gitleaks.outcome == 'failure' && (github.ref == 'refs/heads/main' || github.event_name == 'workflow_dispatch')
30+
env:
31+
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
32+
run: |
33+
echo "Creating detailed security issue report..."
34+
35+
# Get current timestamp
36+
TIMESTAMP=$(date -u +"%Y-%m-%d %H:%M:%S UTC")
37+
38+
# Create an enriched issue body
39+
ISSUE_BODY="## 🚨 Security Alert: Potential Secrets Detected
40+
41+
**Detection Time:** ${TIMESTAMP}
42+
**Branch:** ${GITHUB_REF#refs/heads/}
43+
**Triggered by:** ${{ github.event_name == 'workflow_dispatch' && 'Manual workflow run' || (github.event_name == 'schedule' && 'Monthly scheduled scan' || 'Automated scan') }}
44+
**Detected by:** Gitleaks Security Scanner
45+
46+
### Details
47+
Gitleaks has detected one or more potential secrets or credentials in the codebase.
48+
49+
### Impact
50+
Exposed secrets can lead to unauthorized access, data breaches, or account compromise.
51+
52+
### Next Steps
53+
1. Review the workflow logs for specific details about the detected secrets: ${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}
54+
2. Revoke any exposed credentials immediately
55+
3. Remove the secrets from the codebase
56+
4. Consider using GitHub Secrets or environment variables instead
57+
58+
### Contact
59+
Please reach out to the security team for assistance if needed.
60+
61+
---
62+
*This issue was automatically generated by the Gitleaks security scanning workflow.*"
63+
64+
gh issue create \
65+
--repo ${{ github.repository }} \
66+
--title "Security Alert: Potential secrets detected in ${{ github.event_name == 'pull_request' && format('PR #{0}', github.event.pull_request.number) || 'main branch' }}" \
67+
--body "${ISSUE_BODY}"

.github/workflows/initializer.yml

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
name: Initialize repository
2+
3+
on:
4+
workflow_dispatch:
5+
6+
jobs:
7+
initialize_repo:
8+
runs-on: ubuntu-latest
9+
permissions:
10+
contents: write
11+
pull-requests: write
12+
13+
steps:
14+
- name: Checkout repository
15+
uses: actions/checkout@v4
16+
with:
17+
ref: main
18+
fetch-depth: 0
19+
20+
- name: Setup git
21+
run: |
22+
git config --global user.name "github-actions"
23+
git config --global user.email "[email protected]"
24+
25+
- name: Install GitHub CLI
26+
run: |
27+
sudo apt-get update
28+
sudo apt-get install gh -y
29+
30+
- name: Extract repository and username
31+
id: extract
32+
run: |
33+
REPO_NAME="${{ github.repository }}"
34+
USERNAME=$(echo $REPO_NAME | cut -d'/' -f1)
35+
REPO_NAME_ONLY=$(echo $REPO_NAME | cut -d'/' -f2)
36+
echo "username=$USERNAME" >> $GITHUB_OUTPUT
37+
echo "reponame=$REPO_NAME_ONLY" >> $GITHUB_OUTPUT
38+
39+
- name: Set branch name
40+
id: vars
41+
run: echo "branch=initialize-repo-$(date +%Y%m%d%H%M%S)" >> $GITHUB_OUTPUT
42+
43+
- name: Create develop branch if it doesn't exist
44+
run: |
45+
# Check if develop branch exists
46+
if ! git ls-remote --heads origin develop | grep develop; then
47+
echo "Creating develop branch from main..."
48+
git checkout -b develop
49+
git push -u origin develop
50+
git checkout main # Return to main branch for the rest of the workflow
51+
else
52+
echo "Develop branch already exists."
53+
fi
54+
55+
- name: Replace {reponame} and {username} with actual values in non-workflow files
56+
run: |
57+
REPO_NAME_ONLY="${{ steps.extract.outputs.reponame }}"
58+
USERNAME="${{ steps.extract.outputs.username }}"
59+
REPO_NAME_ESCAPED=$(echo $REPO_NAME_ONLY | sed 's/\//\\\//g')
60+
USERNAME_ESCAPED=$(echo $USERNAME | sed 's/\//\\\//g')
61+
62+
# Modify all files except workflow files
63+
find . -type f -not -path "./.git/*" -not -path "./.github/workflows/*" -exec sed -i "s/{reponame}/$REPO_NAME_ESCAPED/g" {} \;
64+
find . -type f -not -path "./.git/*" -not -path "./.github/workflows/*" -exec sed -i "s/{username}/$USERNAME_ESCAPED/g" {} \;
65+
66+
- name: Remove initializer workflow
67+
run: |
68+
rm -f .github/workflows/initializer.yml
69+
70+
- name: Commit changes
71+
run: |
72+
BRANCH_NAME="${{ steps.vars.outputs.branch }}"
73+
git checkout -b $BRANCH_NAME
74+
75+
# Exclude workflow files to avoid permission errors
76+
git add --all -- ':!.github/workflows'
77+
78+
# Explicitly add the deletion of the initializer workflow
79+
git add .github/workflows/initializer.yml
80+
81+
git commit -m "Initialize repository with repo name ${{ steps.extract.outputs.reponame }} and username ${{ steps.extract.outputs.username }}"
82+
git push origin HEAD:$BRANCH_NAME
83+
84+
- name: Create pull request
85+
env:
86+
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
87+
run: |
88+
BRANCH_NAME="${{ steps.vars.outputs.branch }}"
89+
PR_URL=$(gh pr create --base main --head $BRANCH_NAME --title "Initialize repository" --body "This PR initializes the repository with the actual repository name, with the actual username and removing the initializer workflow.")
90+
91+
# Extract PR number from URL
92+
PR_NUMBER=$(basename $PR_URL)
93+
94+
# Add any desired labels to the pull request
95+
# gh pr edit $PR_NUMBER --add-label "initialization"

.github/workflows/sync-from-main-to-develop.yml

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,27 +8,25 @@ on:
88
jobs:
99
sync_main_into_develop:
1010
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
1113
steps:
1214
- name: Checkout develop branch
13-
uses: actions/checkout@v3
15+
uses: actions/checkout@v4
1416
with:
1517
ref: develop
16-
fetch-depth: 0 # Fetch all history for all branches and tags
18+
fetch-depth: 0
1719

18-
- name: Setup git
20+
- name: Configure Git
1921
run: |
2022
git config --global user.name "github-actions"
2123
git config --global user.email "[email protected]"
2224
2325
- name: Merge main into develop
24-
env:
25-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
2626
run: |
2727
git fetch origin main
2828
git merge origin/main --no-edit
29-
29+
3030
- name: Push changes to develop
31-
env:
32-
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
3331
run: |
3432
git push origin develop

0 commit comments

Comments
 (0)