{"id":28951578,"url":"https://github.com/invokable/search-console-project","last_synced_at":"2025-06-23T15:05:54.238Z","repository":{"id":299362098,"uuid":"1002765852","full_name":"invokable/search-console-project","owner":"invokable","description":null,"archived":false,"fork":false,"pushed_at":"2025-06-16T06:20:44.000Z","size":0,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-06-16T06:31:33.613Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/invokable.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["invokable"],"patreon":null,"open_collective":null,"ko_fi":null,"tidelift":null,"community_bridge":null,"liberapay":null,"issuehunt":null,"lfx_crowdfunding":null,"polar":null,"buy_me_a_coffee":null,"thanks_dev":null,"custom":null}},"created_at":"2025-06-16T05:37:05.000Z","updated_at":"2025-06-16T06:20:47.000Z","dependencies_parsed_at":"2025-06-16T06:43:22.438Z","dependency_job_id":null,"html_url":"https://github.com/invokable/search-console-project","commit_stats":null,"previous_names":["invokable/search-console-project"],"tags_count":0,"template":false,"template_full_name":null,"purl":"pkg:github/invokable/search-console-project","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invokable%2Fsearch-console-project","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invokable%2Fsearch-console-project/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invokable%2Fsearch-console-project/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invokable%2Fsearch-console-project/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/invokable","download_url":"https://codeload.github.com/invokable/search-console-project/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/invokable%2Fsearch-console-project/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":261500631,"owners_count":23168071,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2025-06-23T15:05:50.661Z","updated_at":"2025-06-23T15:05:54.228Z","avatar_url":"https://github.com/invokable.png","language":"PHP","funding_links":["https://github.com/sponsors/invokable"],"categories":[],"sub_categories":[],"readme":"# Search Console Sample Project\n\nThis project is a sample implementation that demonstrates how to use the Google Search Console API with Laravel. It's built on the [laravel-console-starter](https://github.com/invokable/laravel-console-starter) foundation and showcases the [laravel-google-searchconsole](https://github.com/invokable/laravel-google-searchconsole) package.\n\n## Overview\n\nThe application automatically fetches Google Search Console data and generates daily performance reports in markdown table format that are sent via email. It uses service account authentication to securely access the Google Search Console API and runs daily via GitHub Actions.\n\n## Key Features\n\n- **Automated Daily Reports**: Generates daily performance breakdowns for the last 7 days in markdown table format\n- **Service Account Authentication**: Uses Google service account credentials stored as JSON in GitHub Secrets\n- **Email Notifications**: Sends formatted reports via AWS SES\n- **GitHub Actions Integration**: Runs automatically at midnight UTC daily\n- **Multi-site Support**: Handles multiple sites configured in Google Search Console\n\n## Authentication Method\n\nThe service account authentication is configured using a JSON string stored in the `GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION` environment variable (GitHub Secret). This JSON string is converted to an array using `json_decode()` in `config/google.php`:\n\n```php\n'file' =\u003e json_decode(env('GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION', ''), true),\n```\n\nThis method is particularly well-suited for GitHub Actions deployment, as it allows the entire service account credentials to be stored as a single secret.\n\n## Main Files\n\n### `app/Console/Commands/SearchConsoleReport.php`\nThe primary command that orchestrates the report generation process:\n- Fetches all sites from Google Search Console\n- Queries performance data for each site using the ReportQuery\n- Sends consolidated reports via email notification\n- Handles errors gracefully with informative messages\n\n### `app/Notifications/SearchConsoleReportNotification.php`\nFormats and sends the email reports:\n- Generates daily performance data for the last 7 days\n- Creates markdown table format showing daily breakdown by site\n- Formats data into readable email content with proper number formatting\n\n### `app/Search/ReportQuery.php`\nDefines the Search Console API query parameters:\n- Sets date range to last 7 days\n- Configures dimensions and row limits\n- Extends the abstract query class from the search console package\n\n### `config/google.php`\nConfiguration for Google API authentication:\n- Enables service account authentication\n- Processes the JSON credentials from environment variables\n- Sets required scopes for Search Console readonly access\n\n## Setup Instructions\n\n### Prerequisites\n- PHP 8.4+\n- Composer\n- Google Search Console service account with appropriate permissions\n- AWS SES credentials (for email delivery)\n\n### Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/invokable/search-console-project.git\ncd search-console-project\n```\n\n2. Install dependencies:\n```bash\ncomposer install\n```\n\n3. Setup environment:\n```bash\ncp .env.example .env\nphp artisan key:generate\n```\n\n4. Configure environment variables in `.env`:\n```env\n# Google Search Console\nGOOGLE_SERVICE_ENABLED=true\nGOOGLE_SERVICE_ACCOUNT_JSON_LOCATION='{\"type\":\"service_account\",...}'\n\n# Email Configuration\nMAIL_MAILER=ses\nMAIL_FROM_ADDRESS=your-email@domain.com\nMAIL_FROM_NAME=\"Search Console Monitor\"\nMAIL_TO_ADDRESS=recipient@domain.com\nMAIL_TO_NAME=\"Report Recipient\"\n\n# AWS SES\nAWS_ACCESS_KEY_ID=your-access-key\nAWS_SECRET_ACCESS_KEY=your-secret-key\nAWS_DEFAULT_REGION=us-east-1\n```\n\n### Google Service Account Setup\n\n1. Create a service account in Google Cloud Console\n2. Enable the Search Console API\n3. Generate and download the service account key (JSON)\n4. Add the service account email as a user in Google Search Console\n5. Store the entire JSON content as `GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION`\n\n## Usage\n\n### Manual Execution\n```bash\nphp artisan sc:report\n```\n\n### Automated Execution\nThe project includes a GitHub Actions workflow (`.github/workflows/cron.yml`) that runs daily at midnight UTC. Configure the following GitHub Secrets:\n\n- `GOOGLE_SERVICE_ACCOUNT_JSON_LOCATION`\n- `AWS_ACCESS_KEY_ID`\n- `AWS_SECRET_ACCESS_KEY`\n- `AWS_DEFAULT_REGION`\n- `MAIL_FROM_ADDRESS`\n- `MAIL_FROM_NAME`\n- `MAIL_TO_ADDRESS`\n- `MAIL_TO_NAME`\n\n## Testing\n\nRun the test suite:\n```bash\nphp artisan test\n```\n\nCheck code style:\n```bash\nvendor/bin/pint --test\n```\n\nFix code style issues:\n```bash\nvendor/bin/pint\n```\n\n## Report Format\n\nThe generated reports include:\n- **Daily Performance Table**: Markdown table showing daily metrics for each site over the last 7 days\n- **Individual Site Breakdown**: Separate table for each configured site\n- **Daily Metrics**: Clicks, impressions, CTR percentage, and average position for each day\n- **Sorted Data**: Daily data sorted by date (newest first)\n- **Time Period**: Data covers the last 7 days\n- **Timestamp**: Report generation date and time\n\n## Troubleshooting\n\nCommon issues and solutions:\n\n1. **\"No sites found\"**: Ensure the service account email is added as a user in Google Search Console\n2. **Authentication errors**: Verify the service account JSON is properly formatted and has correct permissions\n3. **Email delivery issues**: Check AWS SES configuration and verify sender/recipient email addresses\n\n## LICENSE\nMIT License\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvokable%2Fsearch-console-project","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Finvokable%2Fsearch-console-project","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Finvokable%2Fsearch-console-project/lists"}