Skip to content

Commit 4ae5a7f

Browse files
committed
Try to make deployment repos be strict mirrors of main-repo branches
1 parent eebafac commit 4ae5a7f

9 files changed

Lines changed: 94 additions & 137 deletions
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
name: deploy
1+
name: deploy (dev)
22

33
on:
44
push:

.github/workflows/deploy-prod.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: deploy (prod)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'prod'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
RELEASE_CHANNEL: prod
12+
TARGET_REPO: ${{ vars.REPO }}
13+
TARGET_BRANCH: deploy
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
deploy:
21+
environment:
22+
name: repo-prod
23+
url: https://github.com/${{ env.REPO }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v6
27+
with:
28+
ref: ${{ env.RELEASE_CHANNEL }}
29+
30+
- name: Force-push to target repo
31+
run: |
32+
mkdir -p "$HOME/.ssh"
33+
echo "${{ secrets.SSH_DEPLOY_KEY }}" > "$HOME/.ssh/deploy_key"
34+
chmod 600 "$HOME/.ssh/deploy_key"
35+
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy_key"
36+
37+
git remote add sync-repo "git@github.com:${{ env.TARGET_REPO }}.git"
38+
git branch -u "sync-repo/${{ env.TARGET_BRANCH }}"
39+
git push --force
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
name: deploy (staging)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'staging'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
RELEASE_CHANNEL: staging
12+
TARGET_REPO: ${{ vars.REPO }}
13+
TARGET_BRANCH: deploy
14+
15+
defaults:
16+
run:
17+
shell: bash
18+
19+
jobs:
20+
deploy:
21+
environment:
22+
name: repo-staging
23+
url: https://github.com/${{ env.TARGET_REPO }}
24+
runs-on: ubuntu-latest
25+
steps:
26+
- uses: actions/checkout@v6
27+
with:
28+
ref: ${{ env.RELEASE_CHANNEL }}
29+
30+
- name: Force-push to target repo
31+
run: |
32+
mkdir -p "$HOME/.ssh"
33+
echo "${{ secrets.SSH_DEPLOY_KEY }}" > "$HOME/.ssh/deploy_key"
34+
chmod 600 "$HOME/.ssh/deploy_key"
35+
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy_key"
36+
37+
git remote add sync-repo "git@github.com:${{ env.TARGET_REPO }}.git"
38+
git branch -u "sync-repo/${{ env.TARGET_BRANCH }}"
39+
git push --force

.github/workflows/release-channel-dev.yml

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ jobs:
3434
with:
3535
branch: staging
3636

37-
sync-repo-staging:
37+
deploy-repo-staging:
3838
# We call this workflow manually because it doesn't appear to be triggered automatically by a
3939
# push of the dev branch from the ff-branch job:
40-
uses: ./.github/workflows/sync-repo-staging.yml
40+
uses: ./.github/workflows/deploy-staging.yml
4141
needs: ff-branch-staging
4242
secrets: inherit
4343

@@ -58,9 +58,9 @@ jobs:
5858
with:
5959
branch: prod
6060

61-
sync-repo-prod:
61+
deploy-repo-prod:
6262
# We call this workflow manually because it doesn't appear to be triggered automatically by a
6363
# push of the dev branch from the ff-branch job:
64-
uses: ./.github/workflows/sync-repo-prod.yml
64+
uses: ./.github/workflows/deploy-prod.yml
6565
needs: ff-branch-prod
6666
secrets: inherit

.github/workflows/release-channel-prod.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,9 +37,9 @@ jobs:
3737
with:
3838
branch: prod
3939

40-
sync-repo:
40+
deploy-repo:
4141
# We call this workflow manually because it doesn't appear to be triggered automatically by a
4242
# push of the prod branch from the ff-branch job:
43-
uses: ./.github/workflows/sync-repo-prod.yml
43+
uses: ./.github/workflows/deploy-prod.yml
4444
needs: ff-branch
4545
secrets: inherit

.github/workflows/release-channel-staging.yml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,9 +40,9 @@ jobs:
4040
with:
4141
branch: staging
4242

43-
sync-repo:
43+
deploy-repo:
4444
# We call this workflow manually because it doesn't appear to be triggered automatically by a
4545
# push of the staging branch from the ff-branch job:
46-
uses: ./.github/workflows/sync-repo-staging.yml
46+
uses: ./.github/workflows/deploy-staging.yml
4747
needs: ff-branch
4848
secrets: inherit

.github/workflows/sync-repo-prod.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

.github/workflows/sync-repo-staging.yml

Lines changed: 0 additions & 54 deletions
This file was deleted.

README.md

Lines changed: 7 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -32,26 +32,13 @@ Then open: <http://localhost:3000>
3232
The openUC2 docs site has three GitHub Pages deployments, each with its own repository:
3333

3434
- development/edge release channel: the `master` branch of [openUC2/docs](https://github.com/openUC2/docs); deploys to [docs-dev.openuc2.com](https://docs-dev.openuc2.com).
35-
- staging/beta release channel: the `deploy` branch of [openUC2/docs-staging](https://github.com/openUC2/docs-staging); deploys to [docs-staging.openuc2.com](https://docs-staging.openuc2.com)
36-
- prod/stable release channel: the `deploy` branch of [openUC2/docs-prod](https://github.com/openUC2/docs-prod); deploys to [docs.openuc2.com](https://docs.openuc2.com).
37-
38-
To set up a local development environment which can deploy to all three channels, run:
39-
40-
```bash
41-
git clone git@github.com:openUC2/docs.git
42-
cd docs
43-
git config push.default upstream
44-
git remote add staging git@github.com:openUC2/docs-staging.git
45-
git remote add prod git@github.com:openUC2/docs-prod.git
46-
git fetch --all
47-
git checkout -b deploy/staging staging/deploy
48-
git checkout -b deploy/prod prod/deploy
49-
git checkout master
50-
```
35+
- staging/beta release channel: the `staging` branch of openUC2/docs; automatically mirrored to the `deploy` branch of [openUC2/docs-staging](https://github.com/openUC2/docs-staging), which deploys to [docs-staging.openuc2.com](https://docs-staging.openuc2.com)
36+
- prod/stable release channel: the `prod` branch of openUC2/docs; automatically mirrored to the `deploy` branch of [openUC2/docs-prod](https://github.com/openUC2/docs-prod), which deploys to [docs.openuc2.com](https://docs.openuc2.com).
5137

52-
Then you can fast-forward your local `deploy/staging` and `deploy/prod` branches to the desired commits on your local `master` branch, and you can deploy changes to the staging and prod release channels by pushing your updated local `deploy/staging` and `deploy/prod` branches, respectively, up to GitHub.
38+
After cloning the openUC2/docs repo, then you can fast-forward your local `staging` and `prod` branches to the desired commits on your local `master` branch.
39+
Then you can deploy changes to the staging and prod release channels by pushing your updated local `staging` and `prod` branches, respectively, up to the openUC2/docs repository.
5340
The deployment process should usually be done as follows:
5441

55-
1. Fast-forward the `deploy` branch of the `docs-staging` repo to whichever commit of the `docs` repo that we want to publish.
56-
2. Look at `docs-staging.openuc2.com` and fix any problems.
57-
3. Once the version in the `docs-staging` repo is stable and mature enough for publication, fast-forward the `deploy` branch of the `docs-prod` repo to the publication-ready commit of the `docs-staging` repo.
42+
1. Fast-forward the `staging` branch of the openUC2/docs repo to whichever commit of the `master` branch that we want to publish.
43+
2. Wait for it to build and deploy, then look at `docs-staging.openuc2.com` and fix any problems.
44+
3. Once the version in the `docs-staging` repo is stable and mature enough for publication, fast-forward the `prod` branch of the openUC2/docs repo to the publication-ready commit of the `staging` branch.

0 commit comments

Comments
 (0)