Skip to content

Commit

Permalink
Merge branch 'master' of https://github.com/sau-mili/Counsellor-Web i…
Browse files Browse the repository at this point in the history
…nto mainnn
  • Loading branch information
sau-mili committed May 27, 2024
2 parents 826b3cd + ba3c22c commit b7dcabe
Show file tree
Hide file tree
Showing 38 changed files with 2,046 additions and 486 deletions.
27 changes: 27 additions & 0 deletions .github/workflows/autocomment-issue-close.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
name: Comment on Issue Close

on:
issues:
types: [closed]

jobs:
greet-on-close:
runs-on: ubuntu-latest
permissions:
issues: write
steps:
- name: Greet User
uses: actions/github-script@v5
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const issue = context.payload.issue;
const issueCreator = issue.user.login;
const issueNumber = issue.number;
const greetingMessage = `Hello @${issueCreator}! Your issue #${issueNumber} has been closed. Thank you for your contribution!`;
github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: issueNumber,
body: greetingMessage
});
36 changes: 36 additions & 0 deletions .github/workflows/autocomment-pr-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
name: Auto Comment on PR Merge

on:
pull_request:
types: [closed]

permissions:
issues: write
pull-requests: write

jobs:
comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
if: github.event.pull_request.merged == true

steps:
- name: Checkout Repository
uses: actions/checkout@v2

- name: Add Comment to Issue
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
COMMENT=$(cat <<EOF
{
"body": "🎉 Your pull request has been successfully merged! 🎉 Thank you for your valuable contribution to our project. Your efforts are greatly appreciated. Feel free to reach out if you have any more contributions or if there's anything else we can assist you with. Keep up the fantastic work! 🚀"
}
EOF
)
curl -X POST \
-H "Authorization: Bearer $GITHUB_TOKEN" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT"
37 changes: 37 additions & 0 deletions .github/workflows/autocomment-pr-raise.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Auto Comment on PR

on:
pull_request_target:
types: [opened]

permissions:
issues: write
pull-requests: write

jobs:
comment:
runs-on: ubuntu-latest
permissions:
pull-requests: write
steps:
- name: Add Comment to Pull Request
run: |
COMMENT=$(cat <<EOF
{
"body": "Thank you for submitting your pull request! 🙌 We'll review it as soon as possible. In the meantime, please ensure that your changes align with our [CONTRIBUTING.md](https://github.com/Sayak-Bhunia/mystory/blob/main/CONTRIBUTING.md). If there are any specific instructions or feedback regarding your PR, we'll provide them here. Thanks again for your contribution! 😊"
}
EOF
)
RESPONSE=$(curl -s -o response.json -w "%{http_code}" \
-X POST \
-H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/${{ github.event.pull_request.number }}/comments \
-d "$COMMENT")
cat response.json
if [ "$RESPONSE" -ne 201 ]; then
echo "Failed to add comment"
exit 1
fi
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
45 changes: 45 additions & 0 deletions .github/workflows/close-old-issue.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
name: Close Old Issues

on:
schedule:
- cron: "0 0 * * *"

jobs:
close-issues:
runs-on: ubuntu-latest

steps:
- name: Checkout Repository
uses: actions/checkout@v4

- name: Close Old Issues
run: |
# Fetch all open issues
open_issues=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues?state=open" \
| jq -r '.[] | .number')
for issue in $open_issues; do
# Get the last updated timestamp of the issue
last_updated=$(curl -s -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue" \
| jq -r '.updated_at')
# Calculate the number of days since the issue was last updated
days_since_update=$(( ( $(date +%s) - $(date -d "$last_updated" +%s) ) / 86400 ))
# If the issue has been inactive for more than 30 days, close it
if [ $days_since_update -gt 30 ]; then
# Close the issue
curl -s -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"state":"closed"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue"
# Add a comment explaining why the issue was closed
curl -s -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
-d '{"body":"This issue has been automatically closed because it has been inactive for more than 30 days. If you believe this is still relevant, feel free to reopen it or create a new one. Thank you!"}' \
"https://api.github.com/repos/${{ github.repository }}/issues/$issue/comments"
fi
done
35 changes: 35 additions & 0 deletions .github/workflows/close-old-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
name: Close Stale PRs

on:
schedule:
- cron: '0 0 * * *' # Runs daily at midnight UTC
pull_request:
types:
- opened
- reopened
- synchronize

permissions:
pull-requests: write
issues: write

jobs:
close-stale-prs:
runs-on: ubuntu-latest
permissions:
pull-requests: write

steps:
- name: Close Stale PRs
uses: actions/stale@v7
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
stale-pr-message: 'This PR has been automatically closed due to inactivity from the owner for 15 days.'
days-before-pr-stale: 15
days-before-pr-close: 0
exempt-pr-author: false
exempt-pr-labels: ''
only-labels: ''
operations-per-run: 30
remove-stale-when-updated: true
debug-only: false
37 changes: 37 additions & 0 deletions .github/workflows/close-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: Close Issues on PR Merge

on:
pull_request:
types: [closed]

jobs:
close-issues:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v2

- name: Close linked issues
if: github.event.pull_request.merged == true
run: |
# Extract issue numbers from the PR body
ISSUES=$(jq -r '.pull_request.body' "$GITHUB_EVENT_PATH" | grep -Eo '#[0-9]+' | tr -d '#')
# Loop through each extracted issue number and close the issue
for ISSUE in $ISSUES
do
echo "Closing issue #$ISSUE"
# Post a comment to the issue indicating it was closed by the merged PR
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE/comments \
-d "{\"body\":\"Closed by PR #${{ github.event.pull_request.number }}\"}"
# Close the issue by updating its state to "closed"
curl -X PATCH -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-H "Accept: application/vnd.github.v3+json" \
https://api.github.com/repos/${{ github.repository }}/issues/$ISSUE \
-d "{\"state\":\"closed\"}"
done
9 changes: 9 additions & 0 deletions index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,15 @@
href="https://fonts.googleapis.com/css2?family=ABeeZee&family=Livvic&family=Roboto&family=Source+Code+Pro&display=swap"
rel="stylesheet"
/>
<link
rel="stylesheet"
href="https://cdnjs.cloudflare.com/ajax/libs/font-awesome/5.15.3/css/all.min.css"
/>

<link
href="https://unpkg.com/[email protected]/css/boxicons.min.css"
rel="stylesheet"
/>
<link rel="stylesheet" href="./preloading.css" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Counsellor Portal</title>
Expand Down
14 changes: 7 additions & 7 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"uid": "^2.0.2"
},
"devDependencies": {
"@types/react": "^18.3.2",
"@types/react": "^18.3.3",
"@types/react-dom": "^18.3.0",
"@vitejs/plugin-react": "^4.3.0",
"vite": "^5.2.11"
Expand Down
2 changes: 1 addition & 1 deletion src/App.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const App = () => {

return (
<div className="App">
<Outlet />
<Outlet Dashboard />
</div>
);
};
Expand Down
Loading

0 comments on commit b7dcabe

Please sign in to comment.