build(deps): bump angular_group_across 1 directory with 13 updates #12
Workflow file for this run
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Auto-merge Dependabot PRs | |
permissions: | |
contents: write | |
pull-requests: write | |
on: | |
pull_request: | |
types: | |
- opened | |
- synchronize | |
jobs: | |
auto-merge: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Check for existing open PRs | |
id: check_open_prs | |
run: | | |
pr_count=$(curl -s "https://api.github.com/repos/${{ github.repository }}/pulls?state=open&base=dev" | jq '. | length') | |
echo "Open PR count targeting dev branch: $pr_count" | |
echo "pr_count=$pr_count" >> "$GITHUB_OUTPUT" | |
- name: Exit if no open PRs | |
if: steps.check_open_prs.outputs.pr_count == '0' | |
run: | | |
echo "No open PRs targeting dev branch. Exiting workflow." | |
exit 0 | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- name: Check if PR is created by Dependabot and targets dev branch | |
id: check_dependabot | |
run: | | |
if [[ "${{ env.PR_USER }}" == "dependabot[bot]" ]] && [[ "${{ github.event.pull_request.base.ref }}" == "dev" ]]; then | |
echo "This PR is created by Dependabot and targets the dev branch." | |
echo "is_dependabot=true" >> $GITHUB_ENV | |
else | |
echo "This PR is not created by Dependabot or does not target the dev branch." | |
echo "is_dependabot=false" >> $GITHUB_ENV | |
fi | |
- name: Get pull request details | |
id: get_pr_details | |
run: | | |
pr_url="https://api.github.com/repos/${{ github.repository }}/pulls/${{ github.event.pull_request.number }}" | |
# Extract title from PR details | |
pr_title=$(curl -s "$pr_url" | jq -r '.title') | |
echo "Pull request title: $pr_title" | |
echo "PR_TITLE=$pr_title" >> $GITHUB_ENV # Save PR title to environment variable | |
- name: Extract package name, package manager, previous version, and new version from PR title | |
id: extract_details | |
run: | | |
# Load PR title from environment | |
PR_TITLE="${{ env.PR_TITLE }}" | |
# Extract package name (second word from title) | |
package_name=$(echo "$PR_TITLE" | awk '{print $3}') | |
# Extract package manager if it exists, otherwise use a default (npm_and_yarn) | |
package_manager=$(echo "$PR_TITLE" | grep -oP '(?<=package-manager: )\S+' || echo "npm_and_yarn") | |
# Extract previous and new versions from the title | |
previous_version=$(echo "$PR_TITLE" | grep -oP '\d+\.\d+\.\d+' | head -n 1) | |
new_version=$(echo "$PR_TITLE" | grep -oP '\d+\.\d+\.\d+' | tail -n 1) | |
echo "Extracted parameters:" | |
echo "Package Name: $package_name" | |
echo "Package Manager: $package_manager" | |
echo "Previous Version: $previous_version" | |
echo "New Version: $new_version" | |
# Set extracted values as output variables | |
echo "PACKAGE_NAME=$package_name" >> $GITHUB_ENV | |
echo "PACKAGE_MANAGER=$package_manager" >> $GITHUB_ENV | |
echo "PREVIOUS_VERSION=$previous_version" >> $GITHUB_ENV | |
echo "NEW_VERSION=$new_version" >> $GITHUB_ENV | |
- name: Generate compatibility score URL and request the score | |
id: request_compatibility_score | |
run: | | |
# Generate the URL using extracted values | |
compatibility_url="https://dependabot-badges.githubapp.com/badges/compatibility_score?dependency-name=${{ env.PACKAGE_NAME }}&package-manager=${{ env.PACKAGE_MANAGER }}&previous-version=${{ env.PREVIOUS_VERSION }}&new-version=${{ env.NEW_VERSION }}" | |
echo "Generated URL: $compatibility_url" | |
# Fetch the SVG response | |
svg_response=$(curl -s "$compatibility_url") | |
echo "SVG Response: $svg_response" | |
# Extract the percentage from the <title> tag in the SVG response | |
compatibility_score=$(echo "$svg_response" | grep -oP '(?<=<title>compatibility: )\d+(?=%</title>)') | |
# If the compatibility score is not found, set a default or handle error | |
if [[ -z "$compatibility_score" ]]; then | |
echo "Unable to extract compatibility score. Defaulting to 0." | |
compatibility_score=0 | |
fi | |
echo "Extracted Compatibility Score: $compatibility_score" | |
# Save the score to environment | |
echo "COMPATIBILITY_SCORE=$compatibility_score" >> $GITHUB_ENV | |
- name: Check compatibility score and auto-merge | |
run: | | |
if [[ "$COMPATIBILITY_SCORE" == "100" ]]; then | |
echo "Compatibility score is 100%, auto-merging..." | |
gh pr merge ${{ github.event.pull_request.number }} --auto --squash --delete-branch | |
else | |
echo "Compatibility score is not 100%, skipping auto-merge." | |
fi | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |