-
Notifications
You must be signed in to change notification settings - Fork 120
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add GitHub Actions workflows for caching, dependency updates, linting…
…, testing, security audits, and publishing to Packagist
- Loading branch information
1 parent
8345423
commit 8e3c087
Showing
7 changed files
with
181 additions
and
0 deletions.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
name: Cache Composer Dependencies | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
cache: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
|
||
- name: Cache Composer Dependencies | ||
uses: actions/cache@v3 | ||
with: | ||
path: vendor | ||
key: ${{ runner.os }}-composer-${{ hashFiles('**/composer.lock') }} | ||
restore-keys: | | ||
${{ runner.os }}-composer- | ||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
name: Dependency Update | ||
|
||
on: | ||
schedule: | ||
- cron: '0 3 * * 1' # Runs every Monday at 3:00 AM UTC | ||
|
||
jobs: | ||
update: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
|
||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Update Dependencies | ||
run: composer update --no-progress --no-suggest | ||
|
||
- name: Commit Updated Dependencies | ||
run: | | ||
git config --local user.name "Daggie Douglas Mwangi | ||
git config --local user.email "[email protected]" | ||
git add composer.lock | ||
git commit -m "Update Composer dependencies" || echo "No changes to commit" | ||
- name: Push Changes | ||
run: git push origin main | ||
env: | ||
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Install Composer Dependencies | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
install: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' # Set the PHP version here | ||
|
||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Code Linting | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
lint: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
|
||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run PHP CodeSniffer | ||
run: ./vendor/bin/phpcs --standard=PSR12 src/ |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
name: Publish SDK Package to Packagist | ||
|
||
on: | ||
release: | ||
types: [published] | ||
|
||
jobs: | ||
publish: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
# Step 1: Check out the code | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
# Step 2: Set up PHP environment | ||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' # Specify the PHP version | ||
|
||
# Step 3: Install dependencies | ||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest --no-interaction | ||
|
||
# Step 4: Run tests (optional, but recommended) | ||
- name: Run Tests | ||
run: ./vendor/bin/phpunit | ||
env: | ||
APP_ENV: testing | ||
|
||
# Step 5: Trigger Packagist Update | ||
- name: Publish to Packagist | ||
env: | ||
PACKAGIST_TOKEN: ${{ secrets.PACKAGIST_TOKEN }} | ||
run: | | ||
curl -X POST https://packagist.org/api/update-package?username=africastalking \ | ||
-H "Authorization: Bearer $PACKAGIST_TOKEN" \ | ||
-d '{"repository":{"url":"https://github.com/AfricasTalkingLtd/africastalking-php"}}' |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Security Audit | ||
|
||
on: [push, pull_request, schedule] | ||
|
||
jobs: | ||
audit: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
|
||
- name: Install Composer Dependencies | ||
run: composer install --no-scripts --no-progress --no-suggest | ||
|
||
- name: Run Composer Security Audit | ||
run: composer audit |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: Run Tests | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout code | ||
uses: actions/checkout@v3 | ||
|
||
- name: Set up PHP | ||
uses: shivammathur/setup-php@v2 | ||
with: | ||
php-version: '8.0' | ||
extensions: mbstring, xml # Add other extensions as needed | ||
|
||
- name: Install Composer Dependencies | ||
run: composer install --prefer-dist --no-progress --no-suggest | ||
|
||
- name: Run PHPUnit Tests | ||
run: ./vendor/bin/phpunit |