@@ -17,8 +17,14 @@ permissions:
1717 contents : write
1818
1919jobs :
20- promote-prod-from-staging :
20+ promote-api-v3-main :
2121 runs-on : ubuntu-latest
22+ environment :
23+ name : api-v3-main
24+ url : https://api-v3-main.cfg.embrio.tech
25+ permissions :
26+ contents : write
27+ deployments : write
2228 steps :
2329 - name : Create GitHub App token
2430 id : app-token
@@ -33,40 +39,90 @@ jobs:
3339 token : ${{ steps.app-token.outputs.token }}
3440 ref : ${{ github.ref }}
3541
36- - name : Promote staging image tags to production yamls
42+ - name : Promote mainnet (main-s → main)
3743 run : |
3844 set -euo pipefail
39- promote_pair() {
40- local staging="$1"
41- local prod="$2"
42- local idx qry
43- idx="$(yq '.indexer.image.tag' "$staging")"
44- qry="$(yq '.query.image.tag' "$staging")"
45- export IDX_TAG="$idx" QRY_TAG="$qry"
46- yq -i '.indexer.image.tag = strenv(IDX_TAG)' "$prod"
47- yq -i '.query.image.tag = strenv(QRY_TAG)' "$prod"
48- # Prod now runs this build; avoid duplicate indexers on staging for the same tag.
49- local prod_idx
50- prod_idx="$(yq '.indexer.image.tag' "$prod")"
51- if [ "$idx" = "$prod_idx" ]; then
52- yq -i '.indexer.enabled = false' "$staging"
53- fi
54- }
55- promote_pair environments/main-s.yaml environments/main.yaml
56- promote_pair environments/test-s.yaml environments/test.yaml
45+ staging="environments/main-s.yaml"
46+ prod="environments/main.yaml"
47+ idx="$(yq '.indexer.image.tag' "$staging")"
48+ qry="$(yq '.query.image.tag' "$staging")"
49+ export IDX_TAG="$idx" QRY_TAG="$qry"
50+ yq -i '.indexer.image.tag = strenv(IDX_TAG)' "$prod"
51+ yq -i '.query.image.tag = strenv(QRY_TAG)' "$prod"
52+ prod_idx="$(yq '.indexer.image.tag' "$prod")"
53+ if [ "$idx" = "$prod_idx" ]; then
54+ yq -i '.indexer.enabled = false' "$staging"
55+ fi
56+
57+ - name : Commit and push (mainnet)
58+ env :
59+ GIT_AUTHOR_NAME : api-gitops[bot]
60+ GIT_AUTHOR_EMAIL : ${{ secrets.DEPLOYMENT_APP_ID }}+api-gitops[bot]@users.noreply.github.com
61+ GIT_COMMITTER_NAME : api-gitops[bot]
62+ GIT_COMMITTER_EMAIL : ${{ secrets.DEPLOYMENT_APP_ID }}+api-gitops[bot]@users.noreply.github.com
63+ run : |
64+ set -euo pipefail
65+ git add environments/main.yaml environments/main-s.yaml
66+ if git diff --staged --quiet; then
67+ echo "No mainnet env changes to commit."
68+ exit 0
69+ fi
70+ git commit -m "chore(cd): promote api-v3-main from staging yamls"
71+ git push origin "HEAD:${{ github.ref_name }}"
72+
73+ promote-api-v3-test :
74+ needs : promote-api-v3-main
75+ runs-on : ubuntu-latest
76+ environment :
77+ name : api-v3-test
78+ url : https://api-v3-test.cfg.embrio.tech
79+ permissions :
80+ contents : write
81+ deployments : write
82+ steps :
83+ - name : Create GitHub App token
84+ id : app-token
85+ uses : actions/create-github-app-token@29824e69f54612133e76f7eaac726eef6c875baf
86+ with :
87+ app-id : ${{ secrets.DEPLOYMENT_APP_ID }}
88+ private-key : ${{ secrets.DEPLOYMENT_APP_PRIVATE_KEY }}
89+
90+ - name : Checkout release-please branch
91+ uses : actions/checkout@de0fac2e4500dabe0009e67214ff5f5447ce83dd
92+ with :
93+ token : ${{ steps.app-token.outputs.token }}
94+ ref : ${{ github.ref }}
95+
96+ - name : Pull latest (includes mainnet promotion commit)
97+ run : git pull origin "${{ github.ref_name }}"
98+
99+ - name : Promote testnet (test-s → test)
100+ run : |
101+ set -euo pipefail
102+ staging="environments/test-s.yaml"
103+ prod="environments/test.yaml"
104+ idx="$(yq '.indexer.image.tag' "$staging")"
105+ qry="$(yq '.query.image.tag' "$staging")"
106+ export IDX_TAG="$idx" QRY_TAG="$qry"
107+ yq -i '.indexer.image.tag = strenv(IDX_TAG)' "$prod"
108+ yq -i '.query.image.tag = strenv(QRY_TAG)' "$prod"
109+ prod_idx="$(yq '.indexer.image.tag' "$prod")"
110+ if [ "$idx" = "$prod_idx" ]; then
111+ yq -i '.indexer.enabled = false' "$staging"
112+ fi
57113
58- - name : Commit and push to release-please branch
114+ - name : Commit and push (testnet)
59115 env :
60116 GIT_AUTHOR_NAME : api-gitops[bot]
61117 GIT_AUTHOR_EMAIL : ${{ secrets.DEPLOYMENT_APP_ID }}+api-gitops[bot]@users.noreply.github.com
62118 GIT_COMMITTER_NAME : api-gitops[bot]
63119 GIT_COMMITTER_EMAIL : ${{ secrets.DEPLOYMENT_APP_ID }}+api-gitops[bot]@users.noreply.github.com
64120 run : |
65121 set -euo pipefail
66- git add environments/main.yaml environments/ test.yaml environments/main-s .yaml environments/test-s.yaml
122+ git add environments/test.yaml environments/test-s.yaml
67123 if git diff --staged --quiet; then
68- echo "No environment changes to commit (already promoted) ."
124+ echo "No testnet env changes to commit."
69125 exit 0
70126 fi
71- git commit -m "chore(cd): promote prod image tags from staging yamls"
127+ git commit -m "chore(cd): promote api-v3-test from staging yamls"
72128 git push origin "HEAD:${{ github.ref_name }}"
0 commit comments