Skip to content
This repository was archived by the owner on Aug 6, 2025. It is now read-only.

Commit e56fed8

Browse files
author
Cassidy Schaufele
authored
Continuous Deployment via Github Actions (#402)
* Initial commit of actions deploy PoC * Automatically pull latest tags in dockerfile * Pull pinned version * Lower debug threshold on ssh * Stop all running docker instances * Parallelize production deploy runs * Reconcile file paths for integration and production * Update .github/workflows/deploy-staging-ec2.yml * Delete deploy-staging-ec2.yml * Apply suggestions from review, differentiate branch trigger for integration * Update integration and production release actions with user * Update README.md * Update file path for integration (leftover from staging job) * Correct git pull to git fetch befor checkout
1 parent 92cbbd3 commit e56fed8

File tree

4 files changed

+116
-3
lines changed

4 files changed

+116
-3
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
on:
2+
push:
3+
branches:
4+
- integration
5+
name: Deploy Integration
6+
jobs:
7+
deploy-integration:
8+
if: github.ref == 'refs/heads/integration'
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Install SSH Key
14+
uses: shimataro/[email protected]
15+
with:
16+
key: ${{ secrets.EC2_RSA_KEY }}
17+
known_hosts: ${{ secrets.EC2_KNOWN_HOSTS }}
18+
name: id_rsa
19+
- name: Deploy Integration to Integration
20+
run: |
21+
ssh -l ubuntu ${{ secrets.INTEGRATION_HOST}} -T '
22+
cd docs-worker-pool
23+
git fetch origin
24+
git checkout origin/integration
25+
sudo docker system prune
26+
sudo docker build --no-cache --tag integration .
27+
sudo docker stop $(sudo docker ps -a -q)
28+
sudo docker build --no-cache --tag stage .
29+
sudo sh rundocker.sh
30+
'
31+
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
on:
2+
push:
3+
tags:
4+
- 'v*'
5+
name: Deploy Production
6+
jobs:
7+
deploy-production-1:
8+
if: startsWith(github.ref, 'refs/tags/v')
9+
runs-on: ubuntu-latest
10+
steps:
11+
- name: Checkout
12+
uses: actions/checkout@v2
13+
- name: Install SSH Key
14+
uses: shimataro/[email protected]
15+
with:
16+
key: ${{ secrets.EC2_RSA_KEY }}
17+
known_hosts: ${{ secrets.EC2_KNOWN_HOSTS }}
18+
name: id_rsa
19+
- name: SSH to Production 1
20+
run: |
21+
ssh -l ubuntu ${{ secrets.PRODUCTION_HOST_1}} -T '
22+
cd docker/docs-worker-pool
23+
git fetch origin
24+
git checkout $(git describe --tags)
25+
sudo docker system prune
26+
sudo docker build --no-cache --tag production .
27+
sudo docker stop $(sudo docker ps -a -q)
28+
sudo sh rundocker.sh
29+
'
30+
deploy-production-2:
31+
if: startsWith(github.ref, 'refs/tags/v')
32+
runs-on: ubuntu-latest
33+
steps:
34+
- name: Checkout
35+
uses: actions/checkout@v2
36+
- name: Install SSH Key
37+
uses: shimataro/[email protected]
38+
with:
39+
key: ${{ secrets.EC2_RSA_KEY }}
40+
known_hosts: ${{ secrets.EC2_KNOWN_HOSTS }}
41+
name: id_rsa
42+
- name: SSH to Production 2
43+
run: |
44+
ssh -l ubuntu ${{ secrets.PRODUCTION_HOST_2}} -T '
45+
cd docker/docs-worker-pool
46+
git fetch origin
47+
git checkout $(git describe --tags)
48+
sudo docker system prune
49+
sudo docker build --no-cache --tag production .
50+
sudo docker stop $(sudo docker ps -a -q)
51+
sudo sh rundocker.sh
52+
'
53+

Dockerfile

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,14 +42,14 @@ RUN python3 -m pip install pip==20.2 flit==3.0.0
4242
RUN git clone https://github.com/mongodb/snooty-parser.git && \
4343
cd snooty-parser && \
4444
git fetch --tags && \
45-
git checkout <TAG> && \
45+
git checkout v0.9.6 && \
4646
FLIT_ROOT_INSTALL=1 python3 -m flit install
4747

4848
# install snooty front-end
4949
RUN git clone https://github.com/mongodb/snooty.git snooty
5050
RUN cd snooty && \
5151
git fetch --all && \
52-
git checkout <TAG> && \
52+
git checkout v0.9.8 && \
5353
npm install && \
5454
git clone https://github.com/mongodb/docs-tools.git docs-tools && \
5555
mkdir -p ./static/images && \

README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,4 +49,33 @@ npm install --dev
4949
./node_modules/.bin/eslint .
5050
```
5151

52-
See the [spec doc](https://docs.google.com/document/d/1XZOuuGmozcLQRSDitx0UWhZzJaS4opR1JVwZqDp-N4g/edit?usp=sharing) for more details.
52+
See the [spec doc](https://docs.google.com/document/d/1XZOuuGmozcLQRSDitx0UWhZzJaS4opR1JVwZqDp-N4g/edit?usp=sharing) for more details.
53+
54+
## Branches
55+
Development in this repository can be done via forks or branches. Currently, we support an `integration` and `master` branch, in addition to a `meta` branch. In general, the development workflow is to open pull requests against `integration`, and to promote `integration` to `master` after testing prior to a release.
56+
57+
In general, the git workflow within this repository loosely follows https://www.atlassian.com/git/tutorials/comparing-workflows/gitflow-workflow .
58+
59+
### Meta
60+
`Meta` contains various makefiles and .yaml files used for configuration.
61+
Changes or additions to/of makefiles and .yaml for publishing purposes should be performed against this branch.
62+
There is no general requirement to keep `Meta` up to date with `Master` or `Integration`.
63+
64+
### Integration
65+
`Integration` is treated as a running feature branch that should **always** remain up to date with `master`
66+
67+
### Master
68+
`Master` is treated as our production state branch. In general, pull requests to master should be opened only from integration or a hot-fix feature branch.
69+
If a change is merged into `Master` that is not present in `Integration`, in general, that change should be merged as well from said branch or fork into integration.
70+
71+
## Releasing
72+
docs-worker-pool contains various triggers for release to higher environments. Currently, the repository supports an integration environment (reflecting the state of the integration branch) and a production environment (reflecting the state of the most recent release tag).
73+
74+
### Integration
75+
- Merge a pull request or otherwise push a commit to the integration branch.
76+
- Verify that the deploy-integration-ec2 workflow has executed successfully.
77+
78+
### Production
79+
- Merge outstanding changes within `integration` to `master`.
80+
- Create release tags.
81+
- Verify that the deploy-production-ec2 workflow executed successfully for both job runs across both production instances.

0 commit comments

Comments
 (0)