Skip to content

Commit

Permalink
Merge branch 'ajay-dhangar:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
Hamza1821 authored Oct 13, 2024
2 parents 7ec6acb + d4acee0 commit f17f42a
Show file tree
Hide file tree
Showing 11 changed files with 943 additions and 99 deletions.
66 changes: 46 additions & 20 deletions .github/workflows/greeting.yml
Original file line number Diff line number Diff line change
@@ -1,36 +1,62 @@
name: Auto Greeting for Issues and PRs
name: "Auto Greeting for Issues and PRs"

on:
issues:
types: [opened]
pull_request:
pull_request_target:
types: [opened]

permissions:
issues: write
pull-requests: write

jobs:
greeting:
runs-on: ubuntu-latest

steps:
- name: Post Greeting Message
uses: actions/github-script@v6
with:
script: |
const isIssue = !!context.payload.issue;
const isPR = !!context.payload.pull_request;
- name: Check out repository
uses: actions/checkout@v4

const greetingMessage = `
👋 Hello @${isIssue ? context.payload.issue.user.login : context.payload.pull_request.user.login}, welcome!
- name: Greet first-time contributors
id: greet
uses: actions/first-interaction@v1
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: |
👋 Hi @${{ github.actor }}! Thank you for opening your first issue on the Algo project. We're excited to help you out and appreciate your contribution. Please provide as much detail as possible to assist us in addressing the issue effectively.
Welcome aboard! 😊
pr-message: |
👋 Hi @${{ github.actor }}! Thank you for submitting your first pull request to the Algo project. Great job on the contribution! 🎉 We appreciate your efforts, and our team will review it soon. If you have any questions, feel free to ask. Keep up the great work! 🚀
Thank you for opening this ${isIssue ? "issue" : "pull request"}. We appreciate your effort in helping to improve our Algo project. Our team will review it shortly. In the meantime, if you can provide any additional information or context, feel free to update this ${isIssue ? "issue" : "PR"}.
- name: Assign issue or pull request to a team member
if: github.event_name == 'issues' || github.event_name == 'pull_request_target'
run: |
ISSUE_NUMBER=${{ github.event.issue.number || github.event.pull_request.number }}
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d '{"assignees":["team-member-username"]}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
Please refer to our [CONTRIBUTING.md](https://github.com/ajay-dhangar/algo/blob/main/CONTRIBUTING.md) for guidelines on contributing to this project.
- name: Welcome message for community contributors
if: github.event_name == 'issues' || github.event_name == 'pull_request_target'
uses: EddieHubCommunity/gh-action-community/src/welcome@main
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
issue-message: "👋 Hi @${{ github.actor }}! Thanks for opening this issue. We appreciate your contribution to the Algo project. Our team will review it soon."
pr-message: "🎉 Great job, @${{ github.actor }}! Thank you for submitting your pull request. We appreciate your contribution, and our team will review it shortly."

Thank you for your contribution! 🚀😊
`;
- name: Label first-time issues
if: github.event_name == 'issues'
run: |
ISSUE_NUMBER=${{ github.event.issue.number }}
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d '{"labels":["Algo Contributor's Issue"]}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${ISSUE_NUMBER}"
await github.rest.issues.createComment({
owner: context.repo.owner,
repo: context.repo.repo,
issue_number: isIssue ? context.issue.number : context.payload.pull_request.number,
body: greetingMessage
});
- name: Label first-time pull requests
if: github.event_name == 'pull_request_target'
run: |
PR_NUMBER=${{ github.event.pull_request.number }}
curl -X POST -H "Authorization: token ${{ secrets.GITHUB_TOKEN }}" \
-d '{"labels":["Algo Contributor's PR"]}' \
"https://api.github.com/repos/${{ github.repository }}/issues/${PR_NUMBER}"
68 changes: 68 additions & 0 deletions .github/workflows/lighthouse-report.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
name: Lighthouse Report

on:
pull_request_target:
branches:
- main
- algo-v**

permissions:
contents: read

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
cancel-in-progress: true

jobs:
lighthouse-report:
permissions:
pull-requests: write # for marocchino/sticky-pull-request-comment
name: Lighthouse Report
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/[email protected]

- name: Use Node.js
uses: actions/[email protected]
with:
node-version: 20

- name: Install dependencies
run: npm ci

- name: Build website
run: npm run build

- name: Audit URLs using Lighthouse
id: lighthouse_audit
uses: treosh/[email protected]
with:
urls: |
http://localhost:3000/algo/
http://localhost:3000/algo/docs
http://localhost:3000/algo/blog
configPath: ./.github/workflows/lighthouserc.json
uploadArtifacts: true
temporaryPublicStorage: true

- name: Format lighthouse score
id: format_lighthouse_score
uses: actions/[email protected]
with:
github-token: ${{ secrets.GITHUB_TOKEN }}
script: |
const results = ${{ steps.lighthouse_audit.outputs.manifest }}
const links = ${{ steps.lighthouse_audit.outputs.links }}
const createLighthouseReport = (await import(`${process.env.GITHUB_WORKSPACE}/admin/scripts/formatLighthouseReport.js`)).default;
const comment = createLighthouseReport({ results, links });
core.setOutput("comment", comment);
- name: Add Lighthouse stats as comment
id: comment_to_pr
uses: marocchino/[email protected]
with:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
number: ${{ github.event.pull_request.number }}
header: lighthouse
message: ${{ steps.format_lighthouse_score.outputs.comment }}
20 changes: 20 additions & 0 deletions .github/workflows/lighthouserc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
{
"ci": {
"collect": {
"startServerCommand": "npm run serve",
"startServerReadyPattern": "Serving",
"startServerReadyTimeout": 10000,
"numberOfRuns": 1,
"settings": {
"skipAudits": [
"robots-txt",
"canonical",
"tap-targets",
"is-crawlable",
"works-offline",
"offline-start-url"
]
}
}
}
}
Loading

0 comments on commit f17f42a

Please sign in to comment.