Skip to content

Jeromedia/JM-Laravel-Github-Version-Package

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

40 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Laravel GitHub Service

A Laravel package to fetch and compare GitHub repository versions.

Description

This package provides a simple way to:

  • Get the current version of a Laravel web application (from Git tags).
  • Fetch the latest release tag from a GitHub repository.
  • Compare the two versions to check for updates.

Installation

1. Install the package using Composer

composer require jeromedia/laravel-github-service

2. Publish the configuration - Important

php artisan vendor:publish --provider="Jeromedia\LaravelGithubService\GithubServiceProvider" --tag=config

3. The Github Full APi link for fetching the latest release

https://api.github.com/repos/{OWNER}/{REPO}/releases/latest

4. Add to your .env file

#Github Connect
GITHUB_API_REPO=""
GITHUB_API_OWNER=""
GITHUB_API_VERSION="2022-11-28"
GITHUB_API_URL="https://api.github.com/repos"
GITHUB_API_TOKEN=""
GITHUB_API_CACHE_TTL=3600

GitHub Api Token

1. Get a gitHub Fine-Grained Token

https://github.com/settings/personal-access-tokens

2. Repository access

Select only for the repository you want to get the tag version

3. Repository permissions

Select ONLY "Contents", Metadata will automatically selected

Usage

1. Add the following code to your footer

<div class="container mx-auto relative"
x-data="{ github: '' }"
x-init="fetch('{{route('github.api')}}')
        .then(response => response.text())
        .then(data => { github = data; })">

Somewhere in your footer

<span class="text-stone-400" x-text="github"></span>

2. Add the route to your api routes file or publish the route

Route::get('/github', GithubController::class)->name('github.api');

3. Or publish the route

php artisan vendor:publish --provider="Jeromedia\LaravelGithubService\GithubServiceProvider" --tag=routes

4. Clear the GitHub version cache

php artisan github-service:clear-cache

Development & Contributions

  • Author: [Jerome / Jeromedia Team]
  • Website: [jeromedia.com]
  • Contact: [info@jeromedia.com]
  • License: Private (Internal Use)

Notes

  • This package requires a GitHub personal access token to fetch repository data.
  • Works best with Laravel 9+ and PHP 8+.

About

A Laravel package to fetch and compare GitHub repository versions.

Resources

Stars

Watchers

Forks

Packages

No packages published

Languages