Skip to content

Commit

Permalink
Merge pull request #102 from tanhongit/upgrade
Browse files Browse the repository at this point in the history
Upgrade
  • Loading branch information
tanhongit authored Nov 3, 2023
2 parents 768de44 + dac1c1a commit 0aec3a2
Show file tree
Hide file tree
Showing 23 changed files with 222 additions and 113 deletions.
26 changes: 26 additions & 0 deletions .github/workflows/php-cs-fixer.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
name: Check & fix styling

on: [push]

permissions:
contents: write

jobs:
php-cs-fixer:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: ${{ github.head_ref }}

- name: Run PHP CS Fixer
uses: docker://oskarstark/php-cs-fixer-ga
with:
args: --config=.php-cs-fixer.dist.php --allow-risky=yes

- name: Commit changes
uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: Fix styling
17 changes: 12 additions & 5 deletions .github/workflows/setup_test.yml
Original file line number Diff line number Diff line change
@@ -1,21 +1,28 @@
name: Setup and test
name: Setup & test

on: [ push, pull_request ]

jobs:
tests:
name: Composer setup and tests
runs-on: ubuntu-latest
name: Composer P${{ matrix.php }} - ${{ matrix.os }}
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ ubuntu-latest ]
php: [ '8.1', '8.2' ]
steps:
- name: Setup PHP
uses: shivammathur/setup-php@v2
with:
php-version: '8.2'
php-version: ${{ matrix.php }}

- name: Checkout code
uses: actions/checkout@v3
uses: actions/checkout@v4

- name: Install dependencies
run: |
composer install --no-interaction --no-progress --no-suggest
- name: Run tests
run: |
composer validate --strict
31 changes: 31 additions & 0 deletions .github/workflows/update-changelog.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
name: Update Changelog

on:
release:
types: [released]

permissions:
contents: write

jobs:
update:
runs-on: ubuntu-latest

steps:
- name: Checkout code
uses: actions/checkout@v4
with:
ref: main

- name: Update Changelog
uses: stefanzweifel/changelog-updater-action@v1
with:
latest-version: ${{ github.event.release.name }}
release-notes: ${{ github.event.release.body }}

- name: Commit updated CHANGELOG
uses: stefanzweifel/git-auto-commit-action@v5
with:
branch: main
commit_message: Update CHANGELOG
file_pattern: CHANGELOG.md
5 changes: 5 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,8 @@ storage
.docker
*.log
logs

build
.php-cs-fixer.cache
.phpunit.cache
.phpunit.result.cache
37 changes: 37 additions & 0 deletions .php-cs-fixer.dist.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php

$finder = Symfony\Component\Finder\Finder::create()
->in([
__DIR__ . '/src',
])
->name('*.php')
->ignoreDotFiles(true)
->ignoreVCS(true);

return (new PhpCsFixer\Config())
->setRules([
'@PSR12' => true,
'array_syntax' => ['syntax' => 'short'],
'ordered_imports' => ['sort_algorithm' => 'alpha'],
'no_unused_imports' => true,
'trailing_comma_in_multiline' => true,
'phpdoc_scalar' => true,
'unary_operator_spaces' => true,
'binary_operator_spaces' => true,
'blank_line_before_statement' => [
'statements' => ['break', 'continue', 'declare', 'return', 'throw', 'try'],
],
'phpdoc_single_line_var_spacing' => true,
'phpdoc_var_without_name' => true,
'class_attributes_separation' => [
'elements' => [
'method' => 'one',
],
],
'method_argument_space' => [
'on_multiline' => 'ensure_fully_multiline',
'keep_multiple_spaces_after_comma' => true,
],
'single_trait_insert_per_statement' => true,
])
->setFinder($finder);
30 changes: 15 additions & 15 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,14 @@ you can create a Telegram bot to receive notifications from GitHub or GitLab eve
and manage customization through messages and buttons on Telegram.

<p align="center">
<img alt="GitHub and GitLab notifications to telegram php" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/0ff2d68f-44ea-462f-92c3-6f6b40b16162" />
<img alt="GitHub and GitLab notifications to telegram php" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/0ff2d68f-44ea-462f-92c3-6f6b40b16162" />
</p>

![License](https://img.shields.io/github/license/lbiltech/telegram-git-notifier-app.svg?style=flat-square)
[![Latest Version](https://img.shields.io/github/release/lbiltech/telegram-git-notifier-app.svg?style=flat-square)](https://github.com/lbiltech/telegram-git-notifier-app/releases)
![License](https://img.shields.io/github/license/cslant/telegram-git-notifier-app.svg?style=flat-square)
[![Latest Version](https://img.shields.io/github/release/cslant/telegram-git-notifier-app.svg?style=flat-square)](https://github.com/cslant/telegram-git-notifier-app/releases)
[![StyleCI](https://styleci.io/repos/656960426/shield)](https://styleci.io/repos/656960426)
[![Quality Score](https://img.shields.io/scrutinizer/g/lbiltech/telegram-git-notifier-app.svg?style=flat-square)](https://scrutinizer-ci.com/g/lbiltech/telegram-git-notifier-app)
[![Maintainability](https://api.codeclimate.com/v1/badges/7ccaccebe9cd58ff3df5/maintainability)](https://codeclimate.com/github/lbiltech/telegram-git-notifier-app/maintainability)
[![Quality Score](https://img.shields.io/scrutinizer/g/cslant/telegram-git-notifier-app.svg?style=flat-square)](https://scrutinizer-ci.com/g/cslant/telegram-git-notifier-app)
[![Maintainability](https://api.codeclimate.com/v1/badges/7ccaccebe9cd58ff3df5/maintainability)](https://codeclimate.com/github/cslant/telegram-git-notifier-app/maintainability)

## 📝 Information

Expand All @@ -25,7 +25,7 @@ and manage customization through messages and buttons on Telegram.
1. **GitHub/GitLab Notifications to Telegram**: The package allows you to configure a Telegram bot to receive notifications from various GitHub/GitLab events, including events like **commits, pull requests, issues, releases, and many more**.

<p align="center">
<img alt="GitHub/GitLab Notifications to Telegram" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/462f330f-11d3-43ef-89cf-c70ade57b654" />
<img alt="GitHub/GitLab Notifications to Telegram" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/462f330f-11d3-43ef-89cf-c70ade57b654" />
</p>

2. **Customize Notifications**: You can customize the types of notifications you want to receive through options on Telegram.
Expand All @@ -42,7 +42,7 @@ and manage customization through messages and buttons on Telegram.
- Manage event notifications separately between platforms.

<p align="center">
<img alt="Event Management to Telegram" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/e217a2ad-49b5-4936-a2cd-fe4af66e2bfb" />
<img alt="Event Management to Telegram" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/e217a2ad-49b5-4936-a2cd-fe4af66e2bfb" />
</p>

5. **Easy Integration**:
Expand All @@ -65,9 +65,9 @@ and manage customization through messages and buttons on Telegram.

## 📋 Requirements

- PHP ^8.0
- PHP ^8.1
- [Composer](https://getcomposer.org/)
- Core: [Telegram Git Notifier](https://github.com/lbiltech/telegram-git-notifier)
- Core: [Telegram Git Notifier](https://github.com/cslant/telegram-git-notifier)

## 🔧 Installation

Expand All @@ -90,7 +90,7 @@ Please choose only one of the following two ways to set up the project.
First, please clone and install this project via [Composer](https://getcomposer.org/):

```bash
composer create-project lbiltech/telegram-git-notifier-app
composer create-project cslant/telegram-git-notifier-app
```

After running the command above, you will have the project installed under the `telegram-git-notifier-app` directory,
Expand Down Expand Up @@ -159,7 +159,7 @@ At this time, the source launch process is done, please skip way 2 and go to ste
First, please clone this project and copy the environment file `.env.example` to `.env`:

```bash
git clone [email protected]:lbiltech/telegram-git-notifier-app.git
git clone [email protected]:cslant/telegram-git-notifier-app.git
cd telegram-git-notifier-app
cp .env.example .env
```
Expand Down Expand Up @@ -217,7 +217,7 @@ In this way, we use the proxy in the container and [ngrok](https://ngrok.com/) t
Example:

![image](https://github.com/lbiltech/lemp-docker/assets/35853002/8dc8ba3f-b1e9-4bff-901d-6bb7747acda4)
![image](https://github.com/cslant/lemp-docker/assets/35853002/8dc8ba3f-b1e9-4bff-901d-6bb7747acda4)

2. Download and install [ngrok](https://ngrok.com/download).
2. Continue to run the command in the terminal: `ngrok http <CONTAINER_IP>`
Expand Down Expand Up @@ -373,7 +373,7 @@ You can use all the features of this bot.
🎉🎉

<p align="center">
<img alt="Menu features of this bot" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/1a725130-c7c4-4594-9669-abc6d2dc1fba" />
<img alt="Menu features of this bot" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/1a725130-c7c4-4594-9669-abc6d2dc1fba" />
</p>

**To increase ease of use. Let's create a menu with a list of commands listed for you.**
Expand All @@ -385,7 +385,7 @@ Please send the following message to your bot to create a menu button.
```

<p align="center">
<img alt="Set menu" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/70f79e8f-b075-455d-b928-f721ca5b11cc" /> <img alt="Set menu" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/53af5d51-7aa8-4dd8-99f6-3b55a9971cbe" />
<img alt="Set menu" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/70f79e8f-b075-455d-b928-f721ca5b11cc" /> <img alt="Set menu" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/53af5d51-7aa8-4dd8-99f6-3b55a9971cbe" />
</p>

Now you will need to add the Webhook for your GitHub and GitLab repository to receive notifications.
Expand All @@ -404,7 +404,7 @@ Now you will need to add the Webhook for your GitHub and GitLab repository to re
Here is the first notification you will receive:

<p align="center">
<img alt="Github ping event notification" src="https://github.com/lbiltech/telegram-git-notifier-app/assets/35853002/66b7fffa-d2fa-41f6-8caa-3c1ab96b63be" />
<img alt="Github ping event notification" src="https://github.com/cslant/telegram-git-notifier-app/assets/35853002/66b7fffa-d2fa-41f6-8caa-3c1ab96b63be" />
</p>

## 📌 Add a webhook on your GitLab repository to receive notifications
Expand Down
5 changes: 5 additions & 0 deletions UPGRADING.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
## Upgrading

### Moving from lbiltech/telegram-git-notifier-app to cslant/telegram-git-notifier-app

- Replace any reference in your application from `LbilTech\TelegramGitNotifierApp` to `CSlant\TelegramGitNotifierApp`
20 changes: 12 additions & 8 deletions composer.json
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
{
"name": "lbiltech/telegram-git-notifier-app",
"name": "cslant/telegram-git-notifier-app",
"description": "The PHP app to send notification from Gitlab and Github events to Telegram",
"keywords": [
"lbiltech",
"cslant",
"telegram-bot",
"notify",
"git-webhook",
Expand All @@ -17,16 +17,19 @@
"telegram-git-notifier-app"
],
"type": "project",
"homepage": "https://github.com/lbiltech/telegram-git-notifier-app",
"homepage": "https://github.com/cslant/telegram-git-notifier-app",
"license": "MIT",
"require": {
"php": "^8.0",
"ext-json": "*",
"lbiltech/telegram-git-notifier": "^1.2.0"
"cslant/telegram-git-notifier": "^1.3.1"
},
"require-dev": {
"friendsofphp/php-cs-fixer": "^v3.37.1"
},
"autoload": {
"psr-4": {
"LbilTech\\TelegramGitNotifierApp\\": "src/"
"CSlant\\TelegramGitNotifierApp\\": "src/"
}
},
"authors": [
Expand All @@ -38,18 +41,19 @@
}
],
"support": {
"issues": "https://github.com/lbiltech/telegram-git-notifier-app/issues"
"issues": "https://github.com/cslant/telegram-git-notifier-app/issues"
},
"config": {
"sort-packages": true,
"optimize-autoloader": true
},
"scripts": {
"format": "vendor/bin/php-cs-fixer fix --allow-risky=yes",
"post-install-cmd": [
"bash ./install.sh"
"bash vendor/cslant/telegram-git-notifier/install.sh"
],
"post-update-cmd": [
"bash ./install.sh"
"bash vendor/cslant/telegram-git-notifier/install.sh"
]
}
}
10 changes: 5 additions & 5 deletions index.php
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?php

use LbilTech\TelegramGitNotifier\Exceptions\EntryNotFoundException;
use LbilTech\TelegramGitNotifier\Exceptions\InvalidViewTemplateException;
use LbilTech\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
use LbilTech\TelegramGitNotifier\Exceptions\SendNotificationException;
use LbilTech\TelegramGitNotifierApp\Http\Actions\IndexAction;
use CSlant\TelegramGitNotifier\Exceptions\EntryNotFoundException;
use CSlant\TelegramGitNotifier\Exceptions\InvalidViewTemplateException;
use CSlant\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
use CSlant\TelegramGitNotifier\Exceptions\SendNotificationException;
use CSlant\TelegramGitNotifierApp\Http\Actions\IndexAction;

require __DIR__ . '/init.php';

Expand Down
21 changes: 0 additions & 21 deletions install.sh

This file was deleted.

2 changes: 1 addition & 1 deletion resources/views/tools/menu.php
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
<?php

use LbilTech\TelegramGitNotifierApp\Services\CommandService;
use CSlant\TelegramGitNotifierApp\Services\CommandService;

$menuCommands = CommandService::MENU_COMMANDS ?? [];
?>
Expand Down
14 changes: 8 additions & 6 deletions src/Http/Actions/CallbackAction.php
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
<?php

namespace LbilTech\TelegramGitNotifierApp\Http\Actions;
namespace CSlant\TelegramGitNotifierApp\Http\Actions;

use LbilTech\TelegramGitNotifier\Bot;
use LbilTech\TelegramGitNotifier\Constants\SettingConstant;
use LbilTech\TelegramGitNotifier\Exceptions\InvalidViewTemplateException;
use LbilTech\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
use LbilTech\TelegramGitNotifierApp\Services\CallbackService;
use CSlant\TelegramGitNotifier\Bot;
use CSlant\TelegramGitNotifier\Constants\SettingConstant;
use CSlant\TelegramGitNotifier\Exceptions\InvalidViewTemplateException;
use CSlant\TelegramGitNotifier\Exceptions\MessageIsEmptyException;
use CSlant\TelegramGitNotifierApp\Services\CallbackService;

class CallbackAction
{
Expand All @@ -32,11 +32,13 @@ public function __invoke(): void

if (str_contains($callback, SettingConstant::SETTING_CUSTOM_EVENTS)) {
$this->bot->eventHandle($callback);

return;
}

if (str_contains($callback, SettingConstant::SETTING_BACK)) {
$this->callbackService->answerBackButton($callback);

return;
}

Expand Down
Loading

0 comments on commit 0aec3a2

Please sign in to comment.