2014-07-24 21:31:57 +04:00
# GitHub Pages Health Check
2014-07-24 21:56:54 +04:00
2014-10-27 18:46:13 +03:00
*Checks your GitHub Pages site for common DNS configuration issues*
2014-07-24 21:56:54 +04:00
2023-10-19 18:16:45 +03:00
[![Build Status ](https://github.com/github/pages-health-check/actions/workflows/push-cibuild.yml/badge.svg )](https://github.com/github/pages-health-check/actions/workflows/push-cibuild.yml)
2023-10-09 23:32:17 +03:00
[![Gem Version ](https://badge.fury.io/rb/github-pages-health-check.svg )](http://badge.fury.io/rb/github-pages-health-check)
2014-10-31 17:47:39 +03:00
2014-07-24 21:56:54 +04:00
## Installation
`gem install github-pages-health-check`
## Usage
### Basic Usage
```ruby
2016-02-12 22:44:05 +03:00
> check = GitHubPages::HealthCheck::Site.new("choosealicense.com")
=> #< GitHubPages::HealthCheck::Site @domain =" choosealicense . com " valid ?= true >
2014-07-24 21:56:54 +04:00
> check.valid?
=> true
```
### An invalid domain
```ruby
2016-02-12 22:44:05 +03:00
> check = GitHubPages::HealthCheck::Site.new("foo.github.com")
2014-07-24 21:56:54 +04:00
> check.valid?
=> false
> check.valid!
2016-02-12 23:35:49 +03:00
raises GitHubPages::HealthCheck::Errors::InvalidCNAMEError
2014-07-24 21:56:54 +04:00
```
### Retrieving specific checks
``` ruby
2016-02-12 22:44:05 +03:00
> check.domain.should_be_a_record?
2014-07-24 21:56:54 +04:00
=> true
2016-02-12 22:44:05 +03:00
> check.domain.a_record?
2014-07-24 21:56:54 +04:00
=> true
```
### Getting checks in bulk
2014-08-28 18:55:40 +04:00
```ruby
2014-07-24 21:56:54 +04:00
> check.to_hash
=> {
:cloudflare_ip?=>false,
:old_ip_address?=>false,
:a_record?=>true,
:cname_record?=>false,
:valid_domain?=>true,
:apex_domain?=>true,
:should_be_a_record?=>true,
:pointed_to_github_user_domain?=>false,
2015-04-14 14:44:23 +03:00
:pointed_to_github_pages_ip?=>false,
2014-07-24 21:56:54 +04:00
:pages_domain?=>false,
:valid?=>true
}
> check.to_json
2015-04-14 14:44:23 +03:00
=> "{\"cloudflare_ip?\":false,\"old_ip_address?\":false,\"a_record?\":true,\"cname_record?\":false,\"valid_domain?\":true,\"apex_domain?\":true,\"should_be_a_record?\":true,\"pointed_to_github_user_domain?\":false,\"pointed_to_github_pages_ip?\":false,\"pages_domain?\":false,\"valid?\":true}"
2014-07-24 21:56:54 +04:00
```
2014-08-28 18:55:40 +04:00
### Getting the reason a domain is invalid
```ruby
2016-02-12 22:44:05 +03:00
> check = GitHubPages::HealthCheck::Site.new "developer.facebook.com"
2014-08-28 18:55:40 +04:00
> check.valid?
=> false
> check.reason
=> #< GitHubPages::HealthCheck::InvalidCNAME >
> check.reason.message
=> "CNAME does not point to GitHub Pages"
```
2016-02-17 19:13:11 +03:00
### Repository checks
Repository checks require a personal access or OAuth token with `repo` or scope. This can be passed as the second argument to the Site or Repository constructors like so:
```ruby
check = GitHubPages::HealthCheck::Site.new "github/pages-health-check", access_token: "1234
```
You can also set `OCTOKIT_ACCESS_TOKEN` as an environmental variable, or via a `.env` file in your working directory.
2021-09-08 22:00:58 +03:00
### Command Line
```
./script/check pages.github.com
host: pages.github.com
uri: https://pages.github.com/
nameservers: :default
dns_resolves?: true
proxied?: false
cloudflare_ip?: false
fastly_ip?: false
old_ip_address?: false
a_record?: false
cname_record?: true
mx_records_present?: false
valid_domain?: true
apex_domain?: false
should_be_a_record?: false
cname_to_github_user_domain?: true
cname_to_pages_dot_github_dot_com?: false
cname_to_fastly?: false
pointed_to_github_pages_ip?: false
non_github_pages_ip_present?: false
pages_domain?: true
served_by_pages?: true
valid?: true
reason:
https?: true
enforces_https?: true
https_error:
https_eligible?: true
caa_error:
dns_zone_soa?: false
dns_zone_ns?: false
```