Skip to content

Commit

Permalink
Merge pull request #1 from GrantBirki/init
Browse files Browse the repository at this point in the history
Init
  • Loading branch information
GrantBirki authored Mar 9, 2024
2 parents be87517 + 57e2b42 commit 60bfbd4
Show file tree
Hide file tree
Showing 9 changed files with 228 additions and 0 deletions.
1 change: 1 addition & 0 deletions .github/CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
* @GrantBirki
12 changes: 12 additions & 0 deletions .github/new-pr-comment.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
### 👋 Thanks for opening a pull request!

Here is a trimmed down summary of the deployment process:

1. 🧪 Run a noop deployment with `.noop` as a comment on this PR
1. 👀 Observe the CI and `noop` output on this pull request to ensure it is passing and doing what it is supposed to do
1. ✔️ Obtain an approval/review on this pull request
1. 🚀 Branch deploy your pull request to production with `.deploy`

> If anything goes wrong, rollback with `.deploy main`
1. 🎉 Merge!
51 changes: 51 additions & 0 deletions .github/workflows/deploy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
name: deploy

on:
push:
branches:
- main

permissions:
contents: read

jobs:
deployment-check:
runs-on: ubuntu-latest
outputs: # set outputs for use in downstream jobs
continue: ${{ steps.deployment-check.outputs.continue }}

steps:
# https://github.com/github/branch-deploy/blob/d3c24bd92505e623615b75ffdfac5ed5259adbdb/docs/merge-commit-strategy.md
- name: deployment check
uses: github/branch-deploy@v9
id: deployment-check
with:
merge_deploy_mode: "true"
environment: production

deploy:
if: ${{ needs.deployment-check.outputs.continue == 'true' && github.event_name == 'push' }}
needs: deployment-check
environment: production
runs-on: ubuntu-latest

steps:
- name: checkout
uses: actions/checkout@v4

- uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: install requirements
run: pip install -r requirements.txt

- uses: grantbirki/octodns-action@v1
id: octodns
with:
config_path: production.yaml
doit: '--doit'
env:
CLOUDFLARE_ACCOUNT_ID: ${{ secrets.CLOUDFLARE_ACCOUNT_ID }}
CLOUDFLARE_TOKEN: ${{ secrets.CLOUDFLARE_TOKEN }}
23 changes: 23 additions & 0 deletions .github/workflows/json-yaml-validate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
name: json-yaml-validate
on:
push:
branches:
- main
pull_request:
workflow_dispatch:

permissions:
contents: read
pull-requests: write # enable write permissions for pull request comments

jobs:
json-yaml-validate:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4

- name: json-yaml-validate
id: json-yaml-validate
uses: GrantBirki/json-yaml-validate@v2
with:
comment: "true" # enable comment mode
24 changes: 24 additions & 0 deletions .github/workflows/new-pr.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
name: new pull request

on:
pull_request:
branches:
- main

permissions:
pull-requests: write
contents: read

jobs:
new-pr:
if: github.event_name == 'pull_request' && github.event.action == 'opened'
runs-on: ubuntu-latest

steps:
# Comment on new PR requests with deployment instructions
- uses: actions/checkout@v4
- name: comment
uses: GrantBirki/comment@v2
continue-on-error: true
with:
file: .github/new-pr-comment.md
4 changes: 4 additions & 0 deletions .github/workflows/noop.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@ on:
pull_request:
workflow_dispatch:

permissions:
contents: read
pull-requests: write # enable write permissions for pull request comments

jobs:
noop:
name: noop
Expand Down
21 changes: 21 additions & 0 deletions .github/workflows/unlock-on-merge.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
name: Unlock On Merge

on:
pull_request:
types: [closed]

permissions:
contents: write

jobs:
unlock-on-merge:
runs-on: ubuntu-latest
if: github.event.pull_request.merged == true

steps:
- name: unlock on merge
uses: github/branch-deploy@v9
id: unlock-on-merge
with:
unlock_on_merge_mode: "true" # <-- indicates that this is the "Unlock on Merge Mode" workflow
environment_targets: production
46 changes: 46 additions & 0 deletions config/ghtrending.io.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
"":
- type: ALIAS
value: ghtrending.pages.dev.
octodns:
cloudflare:
proxied: true
auto-ttl: true

- type: MX
values:
- exchange: route3.mx.cloudflare.net.
preference: 5
- exchange: route2.mx.cloudflare.net.
preference: 82
- exchange: route1.mx.cloudflare.net.
preference: 95
octodns:
cloudflare:
proxied: false
auto-ttl: true

- type: TXT
values:
- v=spf1 include:_spf.mx.cloudflare.net ~all
- google-site-verification=MDJ0aMnhpJc7hbCnUs8z0jbizoNXorxW7Q13FenzOpU
octodns:
cloudflare:
proxied: false
auto-ttl: true

ingest:
- type: A
value: 20.172.212.22
octodns:
cloudflare:
proxied: false
auto-ttl: true

data:
- type: CNAME
value: data.ghtrending.io.s3-website-us-east-1.amazonaws.com.
octodns:
cloudflare:
proxied: true
auto-ttl: true
46 changes: 46 additions & 0 deletions production.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
---
providers:
config:
class: octodns.provider.yaml.YamlProvider
directory: ./config
default_ttl: 3600
enforce_order: false

cloudflare:
class: octodns_cloudflare.CloudflareProvider
# Required permissions for API Tokens are Zone:Read, DNS:Read and DNS:Edit.
# Page Rules:Edit is required for managing Page Rules (URLFWD) records.
token: env/CLOUDFLARE_TOKEN
# Optional. Filter by account ID in environments where a token has access
# across more than the permitted number of accounts allowed by Cloudflare.
account_id: env/CLOUDFLARE_ACCOUNT_ID
# Manage Page Rules (URLFWD) records
pagerules: false # disabled for now by me
# Optional. Default: 4. Number of times to retry if a 429 response
# is received.
retry_count: 10
# Optional. Default: 300. Number of seconds to wait before retrying.
retry_period: 300
# Optional. Default: 50. Number of zones per page.
zones_per_page: 50
# Optional. Default: 100. Number of dns records per page.
records_per_page: 100
# Optional. Default: 120. Lowest TTL allowed to be set.
# A different limit for (non-)enterprise zone applies.
# See: https://developers.cloudflare.com/dns/manage-dns-records/reference/ttl
min_ttl: 120

manager:
plan_outputs:
html:
class: octodns.provider.plan.PlanHtml

zones:
# This is a dynamic zone config. The source(s), here `config`, will be
# queried for a list of zone names and each will dynamically be set up to
# match the dynamic entry.
"*":
sources:
- config
targets:
- cloudflare

0 comments on commit 60bfbd4

Please sign in to comment.