Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[server] Create infrastructure to run one-time scripts #389

Open
rhinodavid opened this issue May 23, 2020 · 0 comments
Open

[server] Create infrastructure to run one-time scripts #389

rhinodavid opened this issue May 23, 2020 · 0 comments
Assignees
Labels
⏱ Status: In Progress This is currently being worked on

Comments

@rhinodavid
Copy link
Member

Suppose we need to do something like run a database migration. Right now, we would probably write a script and then connect directly from our personal machine with production credentials to run it.

This works for now, but has a few drawbacks.

First, this requires sharing production credentials with anyone who wants to run a script. Second, it doesn't give us an easy way to have a record of who's done what in in prod. Finally, it doesn't provide an easy code review mechanism since there's no PR process involved.

To remedy these problems, create infrastructure to run scripts in production which are code reviewed and executed by a binary also running in production. Add a way to monitor what code has been executed.

A potential solution might look like this:

An engineer writes a script to do the desired action and creates a PR to commit it to a specific directory in the repo.

Script is code reviewed like any other PR. Author gets approval and merges the PR.

Using GitHub web hooks, UpSwyng Server is notified that a new PR has been merged. It checks to see if there are new scripts in the script directory. If so, a worker job is created. This job builds the script and eventually will execute it. In the meantime, it deletes the file from the repository and commits this merge via a GitHub app/plugin/bot/whatever. Once that's done it executes the script. Upon completion of the script, the worker then takes the script source and inserts some comments about the results of the script (can pipe from stdio). It takes the comments/source and does a second commit to the repo to add the file to a directory of executed scripts.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⏱ Status: In Progress This is currently being worked on
Projects
None yet
Development

No branches or pull requests

2 participants