lewster32 / corporallancot

A Discord bot primarily for recording, searching and retrieving notes and quotes
MIT License
1 stars 2 forks source link

Implement CI with GitHub Actions #3

Closed Bidthedog closed 4 years ago

Bidthedog commented 4 years ago

Would be pretty easy to set up a GitHub action CI process for this to confirm changes have not broken anything, especially when the new unit tests in #2 are in place.

CD is unfortunately not going to be possible with GitHub actions as using the runner for a public repo poses a considerable security risk on the digital ocean box.

Bidthedog commented 4 years ago

See https://github.com/DNIStream/dni.website/tree/master/.github/workflows for examples on how these workflows could work. CI would require simple node build + test, whereas CD would require docker image build + deployment to GitHub packages.

Also need to include a deployment script that can be executed manually on the server. This can be derived from https://github.com/DNIStream/dni.website/blob/master/deploy.sh

I am considering adding K8s to my Digital Ocean box, which may change this method in the future.

Bidthedog commented 4 years ago

Also need to implement code coverage reporting / action failures for coverage below XX%. Need to agree what is sensible for this.

Bidthedog commented 4 years ago

Going to get on with this next week - might include it in the v1.0.0 milestone though its not strictly necessary for a manual deployment. Copying + customising the above pipelines shouldn't take long, though I might need you to set some things up for me on the repo @lewster32 - I'll let you know.

Bidthedog commented 4 years ago

This work also needs to include a linter, which will probably introduce a lot of minor code changes. Going to use eslint.

Bidthedog commented 4 years ago

Working on this in branch: https://github.com/lewster32/corporallancot/tree/feature/19-github-actions

Currently getting a CI failure related to the config.json not existing in the repo; the config file obviously has to be copied into the docker container for the bot to work:

https://github.com/lewster32/corporallancot/runs/792222019?check_suite_focus=true

Now, we can't push this to the repo because it contains sensitive info; what normally happens here is we offload sensitive info to an environment variable. This is handled in docker via the .env file (which is also not pushed to the environment), then handled in the build / deploy agents via environment variables which we can "mock" for CI / integration builds, and set up as secrets in github settings (I do not have access to this link at present):

https://github.com/lewster32/corporallancot/settings/secrets

@lewster32 Can you somehow give me access to the settings in this repo? I'm an owner in the other repos that I do this in, so I'm not sure what level access I'd need to access it and set things up.

I'm also going to need to change how those secrets are injected into the app (related to #18). To allow you to continue running npm start instead of npm run docker:start or npm run docker:watch, I'll need to read in the settings from the .env file instead of the config.json (which we will need to change + push to the repo once the sensitive info has been redacted).

Bidthedog commented 4 years ago

Not yet completed - got the CD to do yet.