1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121
|
# GitHub Pages Health Check
*Checks your GitHub Pages site for common DNS configuration issues*
[](https://github.com/github/pages-health-check/actions/workflows/push-cibuild.yml)
[](http://badge.fury.io/rb/github-pages-health-check)
## Installation
`gem install github-pages-health-check`
## Usage
### Basic Usage
```ruby
> check = GitHubPages::HealthCheck::Site.new("choosealicense.com")
=> #<GitHubPages::HealthCheck::Site @domain="choosealicense.com" valid?=true>
> check.valid?
=> true
```
### An invalid domain
```ruby
> check = GitHubPages::HealthCheck::Site.new("foo.github.com")
> check.valid?
=> false
> check.valid!
raises GitHubPages::HealthCheck::Errors::InvalidCNAMEError
```
### Retrieving specific checks
``` ruby
> check.domain.should_be_a_record?
=> true
> check.domain.a_record?
=> true
```
### Getting checks in bulk
```ruby
> 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,
:pointed_to_github_pages_ip?=>false,
:pages_domain?=>false,
:valid?=>true
}
> check.to_json
=> "{\"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}"
```
### Getting the reason a domain is invalid
```ruby
> check = GitHubPages::HealthCheck::Site.new "developer.facebook.com"
> check.valid?
=> false
> check.reason
=> #<GitHubPages::HealthCheck::InvalidCNAME>
> check.reason.message
=> "CNAME does not point to GitHub Pages"
```
### 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.
### 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
```
|