diff --git a/.circleci/config.yml b/.circleci/config.yml deleted file mode 100644 index f76d6a46f3..0000000000 --- a/.circleci/config.yml +++ /dev/null @@ -1,10 +0,0 @@ -version: 2.1 -orbs: - node: circleci/node@4.1.0 -jobs: - build: - executor: node/default - steps: - - checkout - - run: yarn - - run: yarn test diff --git a/.github/ISSUE_TEMPLATE/bug.md b/.github/ISSUE_TEMPLATE/bug.md new file mode 100644 index 0000000000..ef6c5eebfe --- /dev/null +++ b/.github/ISSUE_TEMPLATE/bug.md @@ -0,0 +1,14 @@ +--- +name: bug +about: Use this template to report any bugs you've encountered related to the project +title: 'What bug did you encounter?' +labels: bug + +--- + +### Expected outcome + + +### Observed outcome + + diff --git a/.github/ISSUE_TEMPLATE/questions.md b/.github/ISSUE_TEMPLATE/questions.md new file mode 100644 index 0000000000..453382d05a --- /dev/null +++ b/.github/ISSUE_TEMPLATE/questions.md @@ -0,0 +1,10 @@ +--- +name: question +about: Use this template to ask any questions about the service +title: 'Whats your question' +labels: question + +--- + +You can elaborate here + diff --git a/.github/ISSUE_TEMPLATE/report-abuse.md b/.github/ISSUE_TEMPLATE/report-abuse.md new file mode 100644 index 0000000000..3924deedce --- /dev/null +++ b/.github/ISSUE_TEMPLATE/report-abuse.md @@ -0,0 +1,13 @@ +--- +name: report-abuse +about: Use this template to report abusive domains +title: 'Report abuse' +labels: report-abuse + +--- + +Domain you want to report: + +### Reason +Explain why you think this domain is being abused + diff --git a/.github/ISSUE_TEMPLATE/suggestions.md b/.github/ISSUE_TEMPLATE/suggestions.md new file mode 100644 index 0000000000..514629d2d5 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/suggestions.md @@ -0,0 +1,8 @@ +--- +name: suggestion +about: Use this template for feedbacks and suggestions +title: 'Feedback/suggestion' +labels: suggestion + +--- + diff --git a/.github/ISSUE_TEMPLATE/support.md b/.github/ISSUE_TEMPLATE/support.md new file mode 100644 index 0000000000..1f305dfdd3 --- /dev/null +++ b/.github/ISSUE_TEMPLATE/support.md @@ -0,0 +1,12 @@ +--- +name: support +about: Use this template if you need any support with your domain +title: 'Support' +labels: support + +--- + +Your domain name: + +Explain any issues you are facing + diff --git a/.github/labeler.yml b/.github/labeler.yml new file mode 100644 index 0000000000..7dc30bf5ac --- /dev/null +++ b/.github/labeler.yml @@ -0,0 +1,6 @@ +domain: + - domains/*.json + +documentation: + - ./*.md + - ./**/*.md diff --git a/.github/workflows/checks.yml b/.github/workflows/checks.yml new file mode 100644 index 0000000000..e8519241f0 --- /dev/null +++ b/.github/workflows/checks.yml @@ -0,0 +1,24 @@ +# https://github.com/actions/labeler + +name: Checks +on: [pull_request_target] + +jobs: + validation: + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: borales/actions-yarn@v2.0.0 + with: + cmd: install + - name: Running tests + uses: borales/actions-yarn@v2.0.0 + with: + cmd: test + label: + runs-on: ubuntu-latest + steps: + - name: Labelling pull request + uses: actions/labeler@main + with: + repo-token: "${{ secrets.GITHUB_TOKEN }}" diff --git a/.github/workflows/publish-records.yml b/.github/workflows/publish-records.yml new file mode 100644 index 0000000000..17bb7bdc0a --- /dev/null +++ b/.github/workflows/publish-records.yml @@ -0,0 +1,25 @@ +name: Publish records + +on: + workflow_dispatch: + name: 'Publish records' + +jobs: + publish: + runs-on: ubuntu-latest + env: + CI: '1' + ENV: production + NC_USER: ${{ secrets.NC_USER }} + NC_API_KEY: ${{ secrets.NC_API_KEY }} + NC_DOMAIN: ${{ secrets.NC_DOMAIN }} + IP_ADDRESS: ${{ secrets.IP_ADDRESS }} + steps: + - uses: actions/checkout@v2 + - uses: borales/actions-yarn@v2.0.0 + with: + cmd: install + - name: Publishing records + uses: borales/actions-yarn@v2.0.0 + with: + cmd: publish-records diff --git a/API.md b/API.md index 288dcb7f64..cd14511c20 100644 --- a/API.md +++ b/API.md @@ -22,6 +22,8 @@ Example (for github pages) - } ``` +NOTE: For github pages users, to fix the 404 you get after registering the domain, add `your-domain.is-a.dev` to your github pages repo in Settings > Github pages > Custom domain. + ## Domains json file The way you register your own domain name is through a pull request. diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md new file mode 100644 index 0000000000..2a3e7da99c --- /dev/null +++ b/CONTRIBUTING.md @@ -0,0 +1,24 @@ +# Contributing +When contributing to this repository, please first discuss the change you wish to make via issue before making a change. + +You should also read up on this project's [code of conduct](./CODE_OF_CONDUCT.md) + +## Pull requests +You can create an pull request for the following reasons - +* Adding, changing or removing a domain file you own +* Fixing a bug in the scripts or CI +* Fix an error in the documentation + +#### Domains +Changes to domain files will follow the given process - +* PR will be reviewed and merged to `main` branch +* Currently, the publishing of records is done manually. This will be automated soon with releases +* The changes should reflect soon after publishing + + +## Issues +* **Report an abusive domain** - Create a new issue with the label `report-abuse` +* **Report a problem with your domain** - Create a new issue with the label `support` +* **Suggestions** - Create a new issue with the label `suggestion` +* **For any questions** - Create a new issue with the label `question` +* **Report any other issues related to this repository** - Create a new issue with any label that fits diff --git a/domains/@.json b/domains/@.json index d271671b6f..52b9663653 100644 --- a/domains/@.json +++ b/domains/@.json @@ -1,4 +1,5 @@ { + "description": "The root domain for is-a.dev website", "owner": { "username": "phenax", "email": "phenax5@gmail.com" diff --git a/domains/abhinavdalal.json b/domains/abhinavdalal.json new file mode 100644 index 0000000000..b6cc7b99cf --- /dev/null +++ b/domains/abhinavdalal.json @@ -0,0 +1,12 @@ +{ + "description": "Abhinav Dalal's website", + "repo": "https://github.com/b-om/b-om.github.io", + "owner": { + "username": "abhinavdalal", + "email": "abhinavdalal@gmail.com" + }, + "record": { + "CNAME": "b-om.github.io", + "URL": "https://abhinavdalal.is-a.dev" + } +} diff --git a/domains/alex.json b/domains/alex.json new file mode 100644 index 0000000000..1dcc6554be --- /dev/null +++ b/domains/alex.json @@ -0,0 +1,12 @@ +{ + "description": "Alex's personal developer website", + "repo": "https://github.com/alexmorrisnz", + "owner": { + "username": "alexmorrisnz", + "email": "alex@navra.nz" + }, + "record": { + "CNAME": "alexmorris.nz", + "URL": "https://alex.is-a.dev" + } +} diff --git a/domains/garlic-os.json b/domains/garlic-os.json index 059a2b09a8..5cc8585dd2 100644 --- a/domains/garlic-os.json +++ b/domains/garlic-os.json @@ -7,6 +7,6 @@ }, "record": { "CNAME": "the-garlic-os.github.io", - "URL": "https://the-garlic-os.is-a.dev" + "URL": "https://garlic-os.is-a.dev" } } diff --git a/domains/yorodm.json b/domains/yorodm.json new file mode 100644 index 0000000000..2c4e81a6d8 --- /dev/null +++ b/domains/yorodm.json @@ -0,0 +1,12 @@ +{ + "description": "/home/yorodm", + "repo": "https://github.com/yorodm/yorodm.github.io", + "owner": { + "username": "yorodm", + "email": "yoandy.rmartinez@gmail.com" + }, + "record": { + "CNAME": "yorodm.github.io", + "URL": "https://yorodm.is-a.dev" + } +} diff --git a/package.json b/package.json index 165904d1cb..e7f7277a11 100644 --- a/package.json +++ b/package.json @@ -3,7 +3,7 @@ "version": "1.0.0", "description": "Register *.is-a.dev domains for free", "scripts": { - "test": "jest", + "test": "ENV=test jest", "publish-records": "yarn test && node ./scripts/register-domains.js" }, "repository": { diff --git a/scripts/register-domains.js b/scripts/register-domains.js index 6d14d85de3..73186f79ab 100644 --- a/scripts/register-domains.js +++ b/scripts/register-domains.js @@ -35,7 +35,10 @@ const main = async () => { }; if (require.main === module) { - main().catch(console.error); + main().catch(e => { + console.error(e); + process.exit(1); + }); } else { module.exports = { toHostList, registerDomains }; } diff --git a/utils/constants.js b/utils/constants.js index 0dc7aa634a..89a9b627fa 100644 --- a/utils/constants.js +++ b/utils/constants.js @@ -1,15 +1,21 @@ const path = require('path'); -const { ENV = 'sandbox' } = process.env; -require('dotenv').config({ path: path.resolve(`.env.${ENV}`) }); + +const { ENV = 'sandbox', CI } = process.env; + +if (!CI) { + require('dotenv').config({ path: path.resolve(`.env.${ENV}`) }); +} const { NC_USER, NC_API_KEY, NC_DOMAIN, IP_ADDRESS } = process.env; +const IS_TEST = ENV === 'test'; + module.exports = { + ENV, VALID_RECORD_TYPES: ['CNAME', 'A', 'ALIAS', 'URL'], NC_DOMAIN: NC_DOMAIN || 'booboo.xyz', - NC_USER: NC_USER || 'test', - NC_API_KEY: NC_API_KEY || 'fake_key', - ENV, - TTL: 5*60, + NC_USER: IS_TEST ? 'testuser' : NC_USER, + NC_API_KEY: IS_TEST ? 'testkey' : NC_API_KEY, IP_ADDRESS, + TTL: 5*60, }; diff --git a/utils/domain-service.js b/utils/domain-service.js index 6a40e53b94..0831f3cb25 100644 --- a/utils/domain-service.js +++ b/utils/domain-service.js @@ -52,6 +52,11 @@ const getDomainService = ({ nc }) => { return { getHosts, setHosts, updateHosts }; }; +if (!NC_API_KEY) { + console.error('NC_API_KEY cannot be empty'); + process.exit(1); +} + const nc = new Namecheap({ user: NC_USER, key: NC_API_KEY,