From fc6df4b19d43c99a96b99c0d39db25e91b21d15d Mon Sep 17 00:00:00 2001 From: divyamb08 Date: Sun, 1 Dec 2024 18:16:13 -0600 Subject: [PATCH 1/2] added co-authors --- .github/workflows/add-coauthors.yml | 50 +++++++++++++++++++++++++++++ README.md | 20 ++++++++++++ 2 files changed, 70 insertions(+) create mode 100644 .github/workflows/add-coauthors.yml diff --git a/.github/workflows/add-coauthors.yml b/.github/workflows/add-coauthors.yml new file mode 100644 index 000000000..e138a6cdb --- /dev/null +++ b/.github/workflows/add-coauthors.yml @@ -0,0 +1,50 @@ +name: Add Co-Authors +on: + pull_request: + types: [closed] + +jobs: + add-coauthors: + if: github.event.pull_request.merged == true + runs-on: ubuntu-latest + permissions: + contents: write + steps: + - name: Checkout code + uses: actions/checkout@v3 + with: + fetch-depth: 0 + + - name: Setup Git + run: | + git config --global user.name "GitHub Actions" + git config --global user.email "actions@github.com" + + - name: Add co-authors + run: | + # Get the merge commit SHA + MERGE_COMMIT_SHA=$(git rev-parse HEAD) + + # Get the base branch (target of PR) + BASE_BRANCH="${{ github.event.pull_request.base.ref }}" + + # Find merge base + MERGE_BASE=$(git merge-base HEAD $BASE_BRANCH) + + # Extract unique contributors + CONTRIBUTORS=$(git log $MERGE_BASE..$MERGE_COMMIT_SHA --format='%aN <%aE>' | sort -u | grep -v 'GitHub Actions') + + # Get the current commit message + COMMIT_MSG=$(git log -1 --pretty=%B) + + # Create new commit message with co-authors + NEW_MSG="$COMMIT_MSG"$'\n\n' + while IFS= read -r contributor; do + NEW_MSG+="Co-authored-by: $contributor"$'\n' + done <<< "$CONTRIBUTORS" + + # Amend the merge commit with updated message + echo "$NEW_MSG" | git commit --amend -F - + + # Force push the changes + git push --force diff --git a/README.md b/README.md index 12a31f333..0f7472752 100644 --- a/README.md +++ b/README.md @@ -734,6 +734,26 @@ For further assistance, please create an issue on the [GitHub repository](https: - Note for Contributors: If you would like to submit a Pull Request (PR), please target the `release` branch instead of `main`. The `release` branch is used for testing new code changes and will be periodically merged into `main` after validation. This approach ensures that only tested features make it into the main branch. +## Git Co-Authors Feature + +This repository includes an automated GitHub Action that preserves contributor attribution when PRs are squashed and merged. The workflow automatically adds `Co-authored-by` lines to the squashed commit message, ensuring that all contributors get proper credit for their work. + +### How it works + +1. When a PR is merged, the GitHub Action triggers automatically +2. It identifies all unique contributors who made commits in the PR +3. It adds their names and emails as `Co-authored-by` lines to the final squashed commit message + +### Example co-authored commit message: +``` +feat: Add new feature + +Co-authored-by: John Doe +Co-authored-by: Jane Smith +``` + +The workflow is configured in `.github/workflows/add-coauthors.yml`. + ## Conclusion Auto_Jobs_Applier_AIHawk provides a significant advantage in the modern job market by automating and enhancing the job application process. With features like dynamic resume generation and AI-powered personalization, it offers unparalleled flexibility and efficiency. Whether you're a job seeker aiming to maximize your chances of landing a job, a recruiter looking to streamline application submissions, or a career advisor seeking to offer better services, Auto_Jobs_Applier_AIHawk is an invaluable resource. By leveraging cutting-edge automation and artificial intelligence, this tool not only saves time but also significantly increases the effectiveness and quality of job applications in today's competitive landscape. From 6b32ceca7cc4493331c53467fab1357c9821373a Mon Sep 17 00:00:00 2001 From: divyamb08 Date: Mon, 2 Dec 2024 19:41:05 -0600 Subject: [PATCH 2/2] hotfix changes --- .github/workflows/add-coauthors.yml | 65 ++++++++++++++++++++++------- CONTRIBUTING.md | 14 +++++++ README.md | 20 --------- 3 files changed, 64 insertions(+), 35 deletions(-) diff --git a/.github/workflows/add-coauthors.yml b/.github/workflows/add-coauthors.yml index e138a6cdb..81c1d75b0 100644 --- a/.github/workflows/add-coauthors.yml +++ b/.github/workflows/add-coauthors.yml @@ -2,13 +2,33 @@ name: Add Co-Authors on: pull_request: types: [closed] + pull_request_review: + types: [submitted] jobs: + check-approval: + runs-on: ubuntu-latest + if: github.event.review.state == 'approved' + steps: + - name: Add approval status comment + uses: actions/github-script@v6 + with: + script: | + const { owner, repo, number } = context.issue; + await github.rest.issues.createComment({ + owner, + repo, + issue_number: number, + body: `✅ PR has been approved! CI process initiated.\nCI Run: ${process.env.GITHUB_SERVER_URL}/${process.env.GITHUB_REPOSITORY}/actions/runs/${process.env.GITHUB_RUN_ID}` + }); + add-coauthors: + needs: check-approval if: github.event.pull_request.merged == true runs-on: ubuntu-latest permissions: contents: write + pull-requests: write steps: - name: Checkout code uses: actions/checkout@v3 @@ -18,7 +38,7 @@ jobs: - name: Setup Git run: | git config --global user.name "GitHub Actions" - git config --global user.email "actions@github.com" + git config --global user.email "noreply@github.com" - name: Add co-authors run: | @@ -31,20 +51,35 @@ jobs: # Find merge base MERGE_BASE=$(git merge-base HEAD $BASE_BRANCH) - # Extract unique contributors - CONTRIBUTORS=$(git log $MERGE_BASE..$MERGE_COMMIT_SHA --format='%aN <%aE>' | sort -u | grep -v 'GitHub Actions') - - # Get the current commit message - COMMIT_MSG=$(git log -1 --pretty=%B) + # Get list of commits in PR + COMMITS=$(git log --format="%H" $MERGE_BASE..$MERGE_COMMIT_SHA) - # Create new commit message with co-authors - NEW_MSG="$COMMIT_MSG"$'\n\n' - while IFS= read -r contributor; do - NEW_MSG+="Co-authored-by: $contributor"$'\n' - done <<< "$CONTRIBUTORS" + # Initialize co-authors list + CO_AUTHORS="" - # Amend the merge commit with updated message - echo "$NEW_MSG" | git commit --amend -F - + # Loop through commits + for commit in $COMMITS; do + # Get commit author email and name + AUTHOR_EMAIL=$(git log -1 --format="%ae" $commit) + AUTHOR_NAME=$(git log -1 --format="%an" $commit) + + # Add to co-authors if not already present + AUTHOR_LINE="Co-authored-by: $AUTHOR_NAME <$AUTHOR_EMAIL>" + if [[ ! $CO_AUTHORS =~ $AUTHOR_LINE ]]; then + CO_AUTHORS="$CO_AUTHORS\n$AUTHOR_LINE" + fi + done - # Force push the changes - git push --force + # Amend the merge commit with co-authors + if [ ! -z "$CO_AUTHORS" ]; then + git fetch origin $BASE_BRANCH + git checkout $BASE_BRANCH + git pull origin $BASE_BRANCH + echo -e "\n$CO_AUTHORS" | git commit --amend -F - + git push origin $BASE_BRANCH + + # Add comment to PR + gh pr comment ${{ github.event.pull_request.number }} --body "✨ Added co-authors to merge commit.\nCI Status: ${GITHUB_SERVER_URL}/${GITHUB_REPOSITORY}/actions/runs/${GITHUB_RUN_ID}" + fi + env: + GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index a9f3ab1bc..5e1406e62 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -199,3 +199,17 @@ Before submitting a PR: - Ask for help when needed The project maintainers reserve the right to reject any contribution that doesn't meet these guidelines or align with the project's goals. + +## Git Co-Authors Feature +This repository includes an automated GitHub Action that preserves contributor attribution when PRs are squashed and merged. The workflow automatically adds `Co-authored-by` lines to the squashed commit message, ensuring that all contributors get proper credit for their work. +### How it works +1. When a PR is merged, the GitHub Action triggers automatically +2. It identifies all unique contributors who made commits in the PR +3. It adds their names and emails as `Co-authored-by` lines to the final squashed commit message +### Example co-authored commit message: +``` +feat: Add new feature +Co-authored-by: John Doe +Co-authored-by: Jane Smith +``` +The workflow is configured in `.github/workflows/add-coauthors.yml`. diff --git a/README.md b/README.md index 0ec3faa8f..86b956f10 100644 --- a/README.md +++ b/README.md @@ -734,26 +734,6 @@ For further assistance, please create an issue on the [GitHub repository](https: - Note for Contributors: If you would like to submit a Pull Request (PR), please target the `release` branch instead of `main`. The `release` branch is used for testing new code changes and will be periodically merged into `main` after validation. This approach ensures that only tested features make it into the main branch. -## Git Co-Authors Feature - -This repository includes an automated GitHub Action that preserves contributor attribution when PRs are squashed and merged. The workflow automatically adds `Co-authored-by` lines to the squashed commit message, ensuring that all contributors get proper credit for their work. - -### How it works - -1. When a PR is merged, the GitHub Action triggers automatically -2. It identifies all unique contributors who made commits in the PR -3. It adds their names and emails as `Co-authored-by` lines to the final squashed commit message - -### Example co-authored commit message: -``` -feat: Add new feature - -Co-authored-by: John Doe -Co-authored-by: Jane Smith -``` - -The workflow is configured in `.github/workflows/add-coauthors.yml`. - ## Conclusion Auto_Jobs_Applier_AIHawk provides a significant advantage in the modern job market by automating and enhancing the job application process. With features like dynamic resume generation and AI-powered personalization, it offers unparalleled flexibility and efficiency. Whether you're a job seeker aiming to maximize your chances of landing a job, a recruiter looking to streamline application submissions, or a career advisor seeking to offer better services, Auto_Jobs_Applier_AIHawk is an invaluable resource. By leveraging cutting-edge automation and artificial intelligence, this tool not only saves time but also significantly increases the effectiveness and quality of job applications in today's competitive landscape.