Skip to content

Commit 3e97a89

Browse files
committed
Continuously deploy to staging and production
Rather than deploying staging from one repository and production from another, switch to using a single repository to deploy to both environments. We keep our pattern of a "develop" and "master" branch but merging to the former will now deploy to staging and the latter to production. We use [GitHub Actions Environments] [0] to vary the necessary secrets for deployment and ensure only certain branches can deploy to a specific environment. [0]: https://docs.github.com/en/actions/how-tos/deploy/configure-and-manage-deployments/manage-environments
1 parent 8fa894a commit 3e97a89

File tree

1 file changed

+48
-9
lines changed

1 file changed

+48
-9
lines changed

.github/workflows/build.yml

Lines changed: 48 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,17 @@
11
name: Build
22

33
on:
4+
workflow_dispatch:
45
push:
56
branches:
67
- master
8+
- develop
79
pull_request:
810

911
jobs:
1012
build:
11-
runs-on: ubuntu-latest
13+
runs-on: [self-hosted, web]
1214
steps:
13-
- name: Only allow pull requests based on master from the develop branch of the current repository
14-
if: ${{ github.base_ref == 'master' && !(github.head_ref == 'develop' && github.event.pull_request.head.repo.full_name == github.repository) }}
15-
run: |
16-
echo "Pull requests based on master can only come from the develop branch of this repository"
17-
echo "Please check your base branch as it should be develop by default"
18-
exit 1
1915
- uses: actions/checkout@v5
2016
- uses: actions/setup-python@v6
2117
with:
@@ -42,15 +38,58 @@ jobs:
4238
run: make build_doxygen_adoc
4339
- name: Build documentation
4440
run: make -j 2
41+
- uses: actions/upload-artifact@v4
42+
with:
43+
name: documentation
44+
path: documentation/html/
45+
if-no-files-found: error
46+
retention-days: 1
47+
include-hidden-files: true
48+
49+
deploy-staging:
50+
needs: build
51+
runs-on: ubuntu-latest
52+
environment:
53+
name: staging
54+
url: ${{ vars.STAGING_URL }}
55+
if: ${{ github.ref == 'refs/heads/develop' }}
56+
steps:
57+
- uses: actions/checkout@v5
58+
- uses: actions/download-artifact@v5
59+
with:
60+
name: documentation
61+
path: documentation/html
62+
- name: Deploy to Mythic Beasts
63+
uses: ./.github/actions/deploy-action
64+
with:
65+
private_ssh_key: ${{ secrets.DEPLOY_SSH_KEY }}
66+
public_bastion_host_keys: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
67+
bastion_host: ${{ secrets.DEPLOY_BASTION_HOST }}
68+
primary_host: ${{ secrets.DEPLOY_PRIMARY_HOST }}
69+
secondary_host: ${{ secrets.DEPLOY_SECONDARY_HOST }}
70+
source: documentation/html/
71+
destination: documentation
72+
73+
deploy-production:
74+
needs: build
75+
runs-on: ubuntu-latest
76+
environment:
77+
name: production
78+
url: ${{ vars.PRODUCTION_URL }}
79+
if: ${{ github.ref == 'refs/heads/master' }}
80+
steps:
81+
- uses: actions/checkout@v5
82+
- uses: actions/download-artifact@v5
83+
with:
84+
name: documentation
85+
path: documentation/html
4586
- name: Deploy to Mythic Beasts
46-
if: ${{ github.ref == 'refs/heads/master' }}
4787
uses: ./.github/actions/deploy-action
4888
with:
4989
private_ssh_key: ${{ secrets.DEPLOY_SSH_KEY }}
5090
public_bastion_host_keys: ${{ secrets.DEPLOY_KNOWN_HOSTS }}
5191
bastion_host: ${{ secrets.DEPLOY_BASTION_HOST }}
5292
primary_host: ${{ secrets.DEPLOY_PRIMARY_HOST }}
5393
secondary_host: ${{ secrets.DEPLOY_SECONDARY_HOST }}
54-
# this needs to match destination: in _config.yml
5594
source: documentation/html/
5695
destination: documentation

0 commit comments

Comments
 (0)