forked from fourdigits/wagtailspace
-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add CI tests and automate CodeRed Cloud deployment
- Loading branch information
Showing
7 changed files
with
111 additions
and
63 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
# CodeRed Cloud deployment configuration. | ||
|
||
[cr] | ||
# Include some generated files which are gitignored. | ||
deploy_include = | ||
config-prd-stats.json | ||
wagtailspace/static/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
name: Test & Deploy | ||
|
||
# This action will be run on the `master` branch | ||
# or on any pull requests going into the `master` branch. | ||
on: | ||
push: | ||
branches: | ||
- master | ||
pull_request: | ||
branches: | ||
- master | ||
jobs: | ||
|
||
quality-control: | ||
name: Quality Control | ||
runs-on: ubuntu-latest | ||
# Test that Django works. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-python@v4 | ||
with: | ||
python-version: 3.8 | ||
- run: pip install -r requirements.txt | ||
- run: python manage.py check | ||
- run: python manage.py makemigrations --check | ||
# Test frontend build. | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 14 | ||
- run: npm -g install yarn | ||
- run: yarn | ||
- run: yarn build | ||
|
||
deploy: | ||
name: Deploy to CodeRed Cloud | ||
# Only run the deployment if the previous checks succeeded. | ||
needs: quality-control | ||
# Only run in the master branch (i.e. not pull requests). | ||
if: github.ref == 'refs/heads/master' | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: 14 | ||
# Build the frontend, since its output is not part of version control. | ||
- name: Build frontend | ||
run: | | ||
npm -g install yarn | ||
yarn | ||
yarn build | ||
# CodeRed Cloud command line tool. | ||
# See: https://www.codered.cloud/docs/cli/ | ||
- name: Install cr tool | ||
run: | | ||
wget -nv -O /usr/local/bin/cr "https://www.codered.cloud/cli/cr-linux" | ||
chmod +x /usr/local/bin/cr | ||
# Run the deployment. | ||
- name: Deploy | ||
run: cr deploy wagtailspace-us | ||
env: | ||
CR_TOKEN: ${{ secrets.cr_token }} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,53 +1,34 @@ | ||
Wagtail Space | ||
============= | ||
Wagtail Space US | ||
================ | ||
|
||
Wagtail Space is a Wagtail event hosted by Four Digits in Arnhem, The Netherlands. | ||
Code for website at: https://us.wagtail.space/, currently hosted on [CodeRed Cloud](https://www.codered.cloud/). | ||
|
||
We like others to organise Wagtail Space events as well. | ||
|
||
If you like to organise a Wagtail meet up, sprint or conference you may use the Wagtail Space name, graphics and website! | ||
|
||
What we propose: | ||
|
||
- Name your Wagtail event: 'Wagtail Space [CityName]'. Eg: 'Wagtail Space Philadelphia'. | ||
- Notify Four Digits and get a subdomain (philadelphia.wagtail.space) | ||
- We list your event on [wagtail.space](https://wagtail.space) | ||
- Provide hosting yourself (supply an ip address) | ||
- Notify Wagtail Core team of your event plans | ||
|
||
|
||
Install | ||
Backend | ||
------- | ||
|
||
Clone this repo: | ||
|
||
git clone [email protected]:wagtail/wagtailspace-us.git | ||
|
||
|
||
Create a Python 3.6 environment and install Python packages: | ||
Create a **Python 3.8** environment and install Python packages: | ||
|
||
python3 -m venv .venv/ | ||
source .venv/bin/activate | ||
pip install -r requirements.txt | ||
|
||
|
||
Configure your database. Copy and edit local.py. (secret key and database credentials). | ||
Install **Postgres 15** and configure a local database. Copy and edit local.py: | ||
|
||
cp wagtailspace/settings/local.py.example wagtailspace/settings/local.py | ||
vi wagtailspace/settings/local.py | ||
|
||
|
||
Migrate and create a user: | ||
|
||
python manage.py migrate | ||
python manage.py createsuperuser | ||
|
||
Build front-end: | ||
|
||
npm install -g yarn | ||
yarn | ||
yarn build | ||
|
||
Runserver: | ||
|
||
python manage.py runserver | ||
|
@@ -56,19 +37,40 @@ Runserver: | |
Frontend | ||
-------- | ||
|
||
Install NodeJS (last tested with version 14). Then install yarn with: | ||
Install **NodeJS 14**. Then install yarn with: | ||
|
||
npm install -g yarn | ||
|
||
Install project packages: | ||
|
||
yarn | ||
|
||
Then build the frontend: | ||
|
||
yarn build | ||
|
||
Run the development web server. This should be run in tandem with Django runserver. | ||
|
||
yarn start | ||
|
||
|
||
Deploying on CodeRed Cloud | ||
-------------------------- | ||
|
||
The https://us.wagtail.space/ site is currently hosted with [CodeRed Cloud](https://www.codered.cloud/). | ||
|
||
**NOTE:** the site will auto-deploy from the master branch on GitHub. However, if you need to manually deploy for some reason, follow the steps below. | ||
|
||
Ensure the latest code is committed and pushed to master. Build the frontend locally: | ||
|
||
git pull origin master | ||
yarn build | ||
|
||
Install the CodeRed deployment tool `pip install cr`. Get an API key from https://app.codered.cloud/ | ||
|
||
cr deploy wagtailspace-us --token "your_api_key" | ||
|
||
|
||
Deploying (Generic) | ||
------------------- | ||
|
||
|
@@ -79,30 +81,10 @@ Build the frontend locally and copy the results to the server: | |
scp wagtailspace/static [email protected]:/path/to/wagtailspace/wagtailspace | ||
scp config-prd-stats.json [email protected]:/path/to/wagtailspace | ||
|
||
|
||
On the server: | ||
|
||
pip install -r requirements.txt | ||
python manage.py collectstatic | ||
python manage.py migrate | ||
|
||
|
||
Restart. | ||
|
||
|
||
Deploying on CodeRed Cloud | ||
-------------------------- | ||
|
||
Build the frontend locally: | ||
|
||
git pull origin master | ||
yarn build | ||
|
||
Copy the code and static assets to the server using SFTP (credentials can be | ||
accessed through CodeRed dashboard at https://app.codered.cloud/) | ||
|
||
cat codered-deploy.txt | sftp [email protected] | ||
|
||
From the CodeRed Dashboard > Websites > Deployment tab click | ||
**Redeploy Production** which will reinitialize the runtime with the new code | ||
(and automatically runs pip install, collectstatic, migrate, etc.). |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters