Skip to content

Commit

Permalink
updated code for failing checks and updated yml file
Browse files Browse the repository at this point in the history
  • Loading branch information
mayur-sose committed Jan 2, 2025
1 parent 9fad510 commit a345d59
Show file tree
Hide file tree
Showing 2 changed files with 56 additions and 1 deletion.
11 changes: 10 additions & 1 deletion .github/update_packages.php
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,15 @@ function get_latest_version(string $packageName) {
?? get_latest_version_from_drupal_org($packageName);
}

/**
* Fetches the latest version of a package from Packagist.
*
* @param string $packageName
* The name of the package.
*
* @return string|null
* The latest version string, or NULL if not found.
*/
function get_latest_version_from_packagist(string $packageName) {
$client = new Client();
$url = "https://repo.packagist.org/p/{$packageName}.json";
Expand All @@ -41,7 +50,7 @@ function get_latest_version_from_packagist(string $packageName) {
// Extract major.minor version (e.g., "13.3.3" becomes "13.x")
$versionParts = explode('.', $latestVersion);
if (count($versionParts) > 1) {
return $versionParts[0] . '.x';
return $versionParts[0] . '.x';
}

return NULL;
Expand Down
46 changes: 46 additions & 0 deletions .github/workflows/update-packages.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
name: Update Packages.yml

on:
schedule:
- cron: '0 0 * * 1' # Runs weekly on Mondays
workflow_dispatch: # Allows manual trigger of the workflow
push:
branches:
- develop # Runs on pushes to the develop branch
paths-ignore:
- .idea/**
- docs/**

jobs:
update-packages:
runs-on: ubuntu-latest

steps:
- name: Run Update Script
run: php update_packages.php

- name: Commit Changes
run: |
git config --local user.name "github-actions[bot]"
git config --local user.email "github-actions[bot]@users.noreply.github.com"
git add packages.yml
git commit -m "Update packages.yml with latest versions"
git push origin develop || echo "No changes to commit"
- name: Create Pull Request
uses: peter-evans/create-pull-request@v4
with:
branch: update-packages
title: Update packages.yml with latest versions
body: |
This pull request updates the `packages.yml` file with the latest stable versions of dependencies.
labels: dependencies

run-cron:
runs-on: ubuntu-latest
steps:
- name: Check out code
uses: actions/checkout@v3

- name: Run script or cron job
run: php update_packages.php

0 comments on commit a345d59

Please sign in to comment.