Skip to content

Commit d164018

Browse files
authored
Easy push button deploy (#3)
Resolved #1 and #2
1 parent 6db6804 commit d164018

File tree

4 files changed

+22
-4
lines changed

4 files changed

+22
-4
lines changed

README.md

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# PokeAPI Data
1+
# PokeAPI Data
22

33
This repository contains:
44

@@ -7,14 +7,27 @@ This repository contains:
77
- [updater](updater): a [Ditto][1] based bot that runs in docker and can update the data stored in this repo
88
- Deployment configs to deploy an instance of the API to [Netlify][2]
99

10+
# Usage
11+
1012
If you'd like to use the JSON for your own purposes, you can apply your own base URL using [Ditto][1]:
1113

1214
```
1315
ditto transform --base-url='https://pokeapi.co'
1416
```
1517

18+
If you're deploying to [Netlify][2], use the button below and remember to set the `BASE_URL` environment variable.
19+
20+
[![Deploy to Netlify](https://www.netlify.com/img/deploy/button.svg)](https://app.netlify.com/start/deploy?repository=https://github.com/pokeapi/api-data)
21+
22+
```bash
23+
# example
24+
BASE_URL='http://pokeapi.co'
25+
```
26+
27+
# Updater Bot
28+
1629
You can manually update the data if necessary. See [the updater bot](updater).
17-
You can run the bot in docker, or read and adapt its update script yourself.
30+
You can run the bot in docker, or read and adapt its update script yourself.
1831

1932

2033
[1]: https://github.com/pokeapi/ditto

build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,11 @@
11
#!/bin/bash
22

3+
[ -z "${BASE_URL}" ] && { echo "Need to set BASE_URL"; exit 1; }
4+
35
set -e
46
set -o pipefail
57
set -x
68

79
yarn run netlify-lambda build functions
8-
ditto transform --base-url='https://pokeapi-prod.netlify.com/' --dest-dir='_dist'
10+
sed -i "s,\$BASE_URL,$BASE_URL," _functions/*.js
11+
ditto transform --base-url="$BASE_URL" --dest-dir='_dist'

functions/resource-list.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import getJson from 'get-json'
22

3-
const baseUrl = "https://pokeapi-prod.netlify.com";
3+
const baseUrl = "$BASE_URL";
44

55
function targetUrlForPath(path) {
66
let target = baseUrl;

updater/README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
# Updater Bot
22

3+
[![Docker Repository on Quay](https://quay.io/repository/pokeapi/updater/status "Docker Repository on Quay")](https://quay.io/repository/pokeapi/updater)
4+
35
## Usage
46

57
First, make sure you can read/write the target repository over SSH.

0 commit comments

Comments
 (0)