Skip to content

Commit 5eda8c2

Browse files
committed
Promote SDKs from staging to production
Stainless-Generated-From: 43ba7db622aaa0a66ac8b1f0b39d9bede4941ed9
1 parent 9e5cc4b commit 5eda8c2

1 file changed

Lines changed: 65 additions & 0 deletions

File tree

.github/workflows/stlc-promote.yml

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
name: Promote SDKs
2+
3+
on:
4+
push:
5+
branches: [main]
6+
7+
permissions:
8+
contents: read
9+
10+
jobs:
11+
promote:
12+
runs-on: ubuntu-latest
13+
env:
14+
PRODUCTION_REPO: imagekit-developer/imagekit-java
15+
PRODUCTION_BRANCH: master
16+
GH_TOKEN: ${{ secrets.SDK_WRITE_TOKEN }}
17+
steps:
18+
- name: Check out staging
19+
uses: actions/checkout@v4
20+
with:
21+
fetch-depth: 0
22+
persist-credentials: false
23+
24+
- name: Fetch production main
25+
run: |
26+
git remote add production \
27+
"https://x-access-token:${GH_TOKEN}@github.com/${PRODUCTION_REPO}.git"
28+
git fetch production "${PRODUCTION_BRANCH}"
29+
30+
- name: Check if production is already in sync
31+
id: diff
32+
run: |
33+
STAGING_SHA=$(git rev-parse origin/main)
34+
PRODUCTION_SHA=$(git rev-parse production/${PRODUCTION_BRANCH})
35+
if [ "$STAGING_SHA" = "$PRODUCTION_SHA" ]; then
36+
echo "Production is already at $STAGING_SHA. Nothing to release."
37+
echo "synced=true" >> "$GITHUB_OUTPUT"
38+
else
39+
echo "synced=false" >> "$GITHUB_OUTPUT"
40+
fi
41+
42+
- name: Push staging main to the release branch on production
43+
if: steps.diff.outputs.synced == 'false'
44+
run: |
45+
git push production origin/main:refs/heads/stainless/release --force
46+
47+
- name: Open or update the release PR on production
48+
if: steps.diff.outputs.synced == 'false'
49+
run: |
50+
EXISTING_PR=$(gh pr list \
51+
--repo "${PRODUCTION_REPO}" \
52+
--head stainless/release \
53+
--state open \
54+
--json number \
55+
--jq '.[0].number')
56+
if [ -z "${EXISTING_PR}" ]; then
57+
gh pr create \
58+
--repo "${PRODUCTION_REPO}" \
59+
--base "${PRODUCTION_BRANCH}" \
60+
--head stainless/release \
61+
--title "Release SDK updates" \
62+
--body "$(git log --oneline production/${PRODUCTION_BRANCH}..origin/main)"
63+
else
64+
echo "Release PR #${EXISTING_PR} already exists. Force-push has updated it."
65+
fi

0 commit comments

Comments
 (0)