diff --git a/updater/README.md b/updater/README.md index 78832b5305..e1acbf81c7 100644 --- a/updater/README.md +++ b/updater/README.md @@ -1,4 +1,4 @@ -# Updater Bot +# Updater Bot [![Docker Repository on Quay](https://quay.io/repository/pokeapi/updater/status "Docker Repository on Quay")](https://quay.io/repository/pokeapi/updater) @@ -6,28 +6,40 @@ First, make sure you can read/write the target repository over SSH. Launch the bot with a volume containing the SSH keys to `/root/.ssh` and an environment variable for email address. -Since this container runs Docker within itself, it needs to run in privileged mode. +Since this container runs [Docker](https://hub.docker.com/_/docker) within itself, it needs to run in privileged mode. -``` +```sh docker run --privileged -v ~/.ssh:/root/.ssh -e COMMIT_EMAIL=example@example.com quay.io/pokeapi/updater ``` -Check the log for failed clones; sometimes Magikarp times out. - -**Note:** Due to lack of support for file permissions, this does not work on Docker for Windows. +Check the log for failed clones, sometimes Magikarp times out. ## Environment Variables ### Required - - `COMMIT_EMAIL` +- `COMMIT_EMAIL` ### Optional See [the Dockerfile](updater/Dockerfile) for the defaults. - - `COMMIT_NAME` - - `COMMIT_MESSAGE` - - `BRANCH_NAME` - - `REPO_POKEAPI` - - `REPO_DATA` +- `COMMIT_NAME` +- `COMMIT_MESSAGE` +- `BRANCH_NAME` +- `REPO_POKEAPI` +- `REPO_DATA` + +## Build Docker image + +```sh +docker build -t pokeapi-updater . +``` + +## Run on Windows + +Your public/private keys with `KeyName` name will be shared with the pokeapi-updater container. Be sure those keys are the ones with write access on https://github.com/PokeAPI/pokeapi + +```pwsh +pwsh Run-Updater.ps1 -KeyName id_rsa -CommitterEmail example@example.com +``` diff --git a/updater/Run-Updater.ps1 b/updater/Run-Updater.ps1 new file mode 100644 index 0000000000..f17564d768 --- /dev/null +++ b/updater/Run-Updater.ps1 @@ -0,0 +1,22 @@ +#!/usr/bin/env pwsh + +param ( + [string]$KeyName = "id_rsa", + [Parameter(Mandatory=$true)][string]$CommitterEmail +) + +docker run -itd --rm --name pokeapi-api-data-updater --privileged -e COMMIT_EMAIL=${CommitterEmail} pokeapi-updater bash + +docker exec pokeapi-api-data-updater mkdir -p /root/.ssh/ + +docker cp ${HOME}/.ssh/${KeyName} pokeapi-api-data-updater:/root/.ssh/id_rsa +docker cp ${HOME}/.ssh/${KeyName}.pub pokeapi-api-data-updater:/root/.ssh/id_rsa.pub +docker cp ${HOME}/.ssh/known_hosts pokeapi-api-data-updater:/root/.ssh/known_hosts + +docker exec pokeapi-api-data-updater chmod 600 /root/.ssh/id_rsa +docker exec pokeapi-api-data-updater chmod 644 /root/.ssh/id_rsa.pub +docker exec pokeapi-api-data-updater chmod 644 /root/.ssh/known_hosts + +docker exec pokeapi-api-data-updater bash cmd.bash + +docker stop pokeapi-api-data-updater