Skip to content

Commit cb8718c

Browse files
committed
Try to auto-sync staging & prod deployments with master
1 parent f364cc7 commit cb8718c

5 files changed

Lines changed: 251 additions & 0 deletions

File tree

Lines changed: 80 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,80 @@
1+
# Note(ethanjli): This CI workflow is a temporary measure to automatically synchronize the
2+
# docs-staging & docs-prod repos with the master branch of the docs repo, so that @beniroquai can
3+
# deploy all changes directly to staging & production. Once we stabilize our staging & prod
4+
# deployments, we should delete this CI workflow!
5+
---
6+
name: release channel (dev)
7+
on:
8+
push:
9+
branches:
10+
- 'master'
11+
- 'main'
12+
- 'edge'
13+
tags:
14+
- 'v[0-9]+.[0-9]+.[0-9]+-dev.*'
15+
- 'v[0-9]+.[0-9]+.[0-9]+-beta.*'
16+
# We want to advance the dev branch to the latest stable release, too:
17+
- 'v[0-9]+.[0-9]+.[0-9]+'
18+
19+
jobs:
20+
ff-branch-staging:
21+
runs-on: ubuntu-latest
22+
permissions:
23+
contents: write
24+
steps:
25+
- uses: lewagon/wait-on-check-action@v1.3.4
26+
with:
27+
ref: ${{ github.ref }}
28+
check-name: 'build'
29+
repo-token: ${{ secrets.GITHUB_TOKEN }}
30+
wait-interval: 10
31+
32+
- uses: actions/checkout@v4
33+
with:
34+
fetch-depth: 0
35+
36+
- run: |
37+
git checkout staging
38+
git merge --ff-only ${{ github.ref_name }}
39+
40+
- uses: ad-m/github-push-action@v0.8.0
41+
with:
42+
branch: staging
43+
44+
sync-repo-staging:
45+
# We call this workflow manually because it doesn't appear to be triggered automatically by a
46+
# push of the dev branch from the ff-branch job:
47+
uses: ./.github/workflows/sync-repo-staging.yml
48+
needs: ff-branch-staging
49+
secrets: inherit
50+
51+
ff-branch-prod:
52+
runs-on: ubuntu-latest
53+
permissions:
54+
contents: write
55+
steps:
56+
- uses: lewagon/wait-on-check-action@v1.3.4
57+
with:
58+
ref: ${{ github.ref }}
59+
check-name: 'build'
60+
repo-token: ${{ secrets.GITHUB_TOKEN }}
61+
wait-interval: 10
62+
63+
- uses: actions/checkout@v4
64+
with:
65+
fetch-depth: 0
66+
67+
- run: |
68+
git checkout prod
69+
git merge --ff-only ${{ github.ref_name }}
70+
71+
- uses: ad-m/github-push-action@v0.8.0
72+
with:
73+
branch: prod
74+
75+
sync-repo-prod:
76+
# We call this workflow manually because it doesn't appear to be triggered automatically by a
77+
# push of the dev branch from the ff-branch job:
78+
uses: ./.github/workflows/sync-repo-prod.yml
79+
needs: ff-branch-prod
80+
secrets: inherit
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
---
2+
name: release channel (prod)
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+'
7+
8+
jobs:
9+
ff-branch:
10+
runs-on: ubuntu-latest
11+
permissions:
12+
contents: write
13+
steps:
14+
- uses: lewagon/wait-on-check-action@v1.3.4
15+
with:
16+
ref: ${{ github.ref }}
17+
check-name: 'build'
18+
repo-token: ${{ secrets.GITHUB_TOKEN }}
19+
wait-interval: 10
20+
21+
- uses: actions/checkout@v4
22+
with:
23+
fetch-depth: 0
24+
25+
- run: |
26+
git checkout prod
27+
git merge --ff-only ${{ github.ref_name }}
28+
29+
- uses: ad-m/github-push-action@v0.8.0
30+
with:
31+
branch: prod
32+
33+
sync-repo:
34+
# We call this workflow manually because it doesn't appear to be triggered automatically by a
35+
# push of the prod branch from the ff-branch job:
36+
uses: ./.github/workflows/sync-repo-prod.yml
37+
needs: ff-branch
38+
secrets: inherit
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
---
2+
name: release channel (staging)
3+
on:
4+
push:
5+
tags:
6+
- 'v[0-9]+.[0-9]+.[0-9]+-staging.*'
7+
- 'v[0-9]+.[0-9]+.[0-9]+-beta.*'
8+
# We want to advance the staging branch to the latest stable release, too:
9+
- 'v[0-9]+.[0-9]+.[0-9]+'
10+
11+
jobs:
12+
ff-branch:
13+
runs-on: ubuntu-latest
14+
permissions:
15+
contents: write
16+
steps:
17+
- uses: lewagon/wait-on-check-action@v1.3.4
18+
with:
19+
ref: ${{ github.ref }}
20+
check-name: 'build'
21+
repo-token: ${{ secrets.GITHUB_TOKEN }}
22+
wait-interval: 10
23+
24+
- uses: actions/checkout@v4
25+
with:
26+
fetch-depth: 0
27+
28+
- run: |
29+
git checkout staging
30+
git merge --ff-only ${{ github.ref_name }}
31+
32+
- uses: ad-m/github-push-action@v0.8.0
33+
with:
34+
branch: staging
35+
36+
sync-repo:
37+
# We call this workflow manually because it doesn't appear to be triggered automatically by a
38+
# push of the staging branch from the ff-branch job:
39+
uses: ./.github/workflows/sync-repo-staging.yml
40+
needs: ff-branch
41+
secrets: inherit
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: sync repo (prod)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'prod'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
REPOSITORY_OWNER: ${{ github.repository_owner }}
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: repo-prod
21+
url: https://github.com/${{ env.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v6
25+
with:
26+
ref: prod
27+
28+
- name: Add remote branch ${{ env.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}/deploy
29+
run: |
30+
mkdir -p "$HOME/.ssh"
31+
echo "${{ secrets.SSH_DEPLOY_KEY }}" > "$HOME/.ssh/deploy_key"
32+
chmod 600 "$HOME/.ssh/deploy_key"
33+
34+
export GIT_SSH_COMMAND="ssh -i $$HOME/.ssh/deploy_key"
35+
git remote add prod git@github.com:${{ vars.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}.git
36+
git fetch --all
37+
38+
- name: Fast-forward deployment branch
39+
run: |
40+
git checkout -b deploy/prod --track prod/deploy
41+
git merge --ff-only prod
42+
43+
- name: Push to remote repo
44+
run: |
45+
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy_key"
46+
git push
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
name: sync repo (staging)
2+
3+
on:
4+
push:
5+
branches:
6+
- 'staging'
7+
workflow_call:
8+
workflow_dispatch:
9+
10+
env:
11+
REPOSITORY_OWNER: ${{ github.repository_owner }}
12+
13+
defaults:
14+
run:
15+
shell: bash
16+
17+
jobs:
18+
deploy:
19+
environment:
20+
name: repo-staging
21+
url: https://github.com/${{ env.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}
22+
runs-on: ubuntu-latest
23+
steps:
24+
- uses: actions/checkout@v6
25+
with:
26+
ref: staging
27+
28+
- name: Add remote branch ${{ env.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}/deploy
29+
run: |
30+
mkdir -p "$HOME/.ssh"
31+
echo "${{ secrets.SSH_DEPLOY_KEY }}" > "$HOME/.ssh/deploy_key"
32+
chmod 600 "$HOME/.ssh/deploy_key"
33+
34+
export GIT_SSH_COMMAND="ssh -i $$HOME/.ssh/deploy_key"
35+
git remote add staging git@github.com:${{ vars.REPOSITORY_OWNER }}/${{ vars.REPOSITORY_NAME }}.git
36+
git fetch --all
37+
38+
- name: Fast-forward deployment branch
39+
run: |
40+
git checkout -b deploy/staging --track staging/deploy
41+
git merge --ff-only staging
42+
43+
- name: Push to remote repo
44+
run: |
45+
export GIT_SSH_COMMAND="ssh -i $HOME/.ssh/deploy_key"
46+
git push

0 commit comments

Comments
 (0)