diff --git a/.github/workflows/update-packages.yml b/.github/workflows/update-packages.yml index b7183e9b..becbc31a 100644 --- a/.github/workflows/update-packages.yml +++ b/.github/workflows/update-packages.yml @@ -30,7 +30,7 @@ jobs: php-version: '8.1' tools: composer - # Step 3: Add/Update Dependencies + # Step 3: Add Guzzle Dependency - name: Add Guzzle Dependency run: composer require guzzlehttp/guzzle:^7.4 @@ -38,31 +38,35 @@ jobs: - name: Install Dependencies run: composer install - # Step 5: Run Update Script + # Step 5: Reset Composer Changes + - name: Reset Composer Changes + run: | + git checkout -- composer.json composer.lock + + # Step 6: Run Update Script - name: Run Update Script run: php .github/update_packages.php - # Step 6: Reset or Recreate Branch - - name: Reset or Recreate Branch + # Step 7: Create Unique Branch and Commit Changes + - name: Create Unique Branch run: | + TIMESTAMP=$(date +'%Y%m%d%H%M%S') + BRANCH_NAME="update-packages-${TIMESTAMP}" git config --local user.name "github-actions[bot]" git config --local user.email "github-actions[bot]@users.noreply.github.com" - git branch -D update-packages || true - git checkout -b update-packages + git checkout -b "$BRANCH_NAME" git add config/packages.yml - git commit -m "Update dependencies in packages.yml" - git push origin update-packages --force + git diff --staged --quiet && echo "No changes to commit" || git commit -m "Update dependencies in packages.yml" + git push origin "$BRANCH_NAME" - # Step 7: Create or Update Pull Request + # Step 8: Create Pull Request - name: Create Pull Request uses: peter-evans/create-pull-request@v4 with: token: ${{ secrets.GITHUB_TOKEN }} - branch: update-packages + branch: ${{ steps.create-unique-branch.outputs.branch_name }} base: develop - title: Update packages.yml with latest versions + title: Update packages.yml with latest versions (Run ${{ steps.create-unique-branch.outputs.branch_name }}) body: | This pull request updates the `packages.yml` file with the latest stable versions of dependencies. - If no changes are detected, this is a placeholder PR for consistency. labels: dependencies - delete-branch: true