Skip to content

Commit cf3754e

Browse files
authored
Add trigger SaaS build action (baserow#4106)
1 parent a769442 commit cf3754e

File tree

1 file changed

+82
-0
lines changed

1 file changed

+82
-0
lines changed

.github/workflows/ci.yml

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ jobs:
2727
runs-on: ubuntu-latest
2828
outputs:
2929
should_build_and_publish: ${{ steps.setflag.outputs.should_build_and_publish }}
30+
should_trigger_saas: ${{ steps.setflag.outputs.should_trigger_saas }}
3031
steps:
3132
- id: setflag
3233
shell: bash
@@ -40,6 +41,12 @@ jobs:
4041
echo "should_build_and_publish=false" >> "$GITHUB_OUTPUT"
4142
fi
4243
44+
if [[ -n "${{ secrets.GITLAB_SAAS_PAT }}" ]]; then
45+
echo "should_trigger_saas=true" >> "$GITHUB_OUTPUT"
46+
else
47+
echo "should_trigger_saas=false" >> "$GITHUB_OUTPUT"
48+
fi
49+
4350
# ==========================================================================
4451
# BUILD STAGE - Build Docker images for backend and frontend
4552
# ==========================================================================
@@ -1104,3 +1111,78 @@ jobs:
11041111
TARGET=${{ env.RELEASE_DOCKER_REPOSITORY }}/cloudron:develop-latest
11051112
echo "Publishing $SOURCE → $TARGET"
11061113
docker buildx imagetools create -t $TARGET $SOURCE
1114+
1115+
trigger-saas-build:
1116+
name: Trigger SaaS GitLab Pipeline
1117+
runs-on: ubuntu-latest
1118+
needs:
1119+
- build-final-backend
1120+
- build-final-web-frontend
1121+
- build-final-all-in-one
1122+
- check-build-and-publish
1123+
if: needs.check-build-and-publish.outputs.should_build_and_publish == 'true' && needs.check-build-and-publish.outputs.should_trigger_saas == 'true' && github.ref_name == 'develop'
1124+
env:
1125+
GITLAB_SAAS_PAT: ${{ secrets.GITLAB_SAAS_PAT }}
1126+
GIT_USER_NAME: "Baserow CI"
1127+
GIT_USER_EMAIL: "ci@baserow.io"
1128+
steps:
1129+
- name: Checkout core repo
1130+
uses: actions/checkout@v4
1131+
1132+
- name: Clone SaaS repository from GitLab
1133+
run: |
1134+
echo "🔄 Cloning baserow-saas..."
1135+
git clone -b develop https://oauth2:${GITLAB_SAAS_PAT}@gitlab.com/baserow/baserow-saas.git saas
1136+
cd saas
1137+
1138+
- name: Update image version files
1139+
working-directory: saas
1140+
run: |
1141+
echo "🧩 Generating updated image references..."
1142+
1143+
BACKEND_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend:ci-tested-${{ github.sha }}"
1144+
BACKEND_DEV_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/backend_dev:ci-${{ github.sha }}"
1145+
WEB_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend:ci-tested-${{ github.sha }}"
1146+
WEB_DEV_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/web-frontend_dev:ci-${{ github.sha }}"
1147+
ALL_IN_ONE_IMAGE="${{ env.REGISTRY }}/${{ env.IMAGE_REPO }}/baserow:ci-tested-${{ github.sha }}"
1148+
1149+
echo "$BACKEND_IMAGE" > plugins/saas/backend/build_from_image.version
1150+
echo "$BACKEND_DEV_IMAGE" > plugins/saas/backend/build_from_dev_image.version
1151+
echo "$WEB_IMAGE" > plugins/saas/web-frontend/build_from_image.version
1152+
echo "$WEB_DEV_IMAGE" > plugins/saas/web-frontend/build_from_dev_image.version
1153+
echo "$ALL_IN_ONE_IMAGE" > all_in_one_image.version
1154+
1155+
echo "✅ Updated image references:"
1156+
cat plugins/saas/backend/build_from_image.version
1157+
cat plugins/saas/web-frontend/build_from_image.version
1158+
cat all_in_one_image.version
1159+
1160+
- name: Commit and push changes to GitLab
1161+
working-directory: saas
1162+
run: |
1163+
echo "📝 Committing and pushing changes to GitLab..."
1164+
1165+
git config user.name "${GIT_USER_NAME}"
1166+
git config user.email "${GIT_USER_EMAIL}"
1167+
1168+
git add \
1169+
plugins/saas/backend/build_from_image.version \
1170+
plugins/saas/backend/build_from_dev_image.version \
1171+
plugins/saas/web-frontend/build_from_image.version \
1172+
plugins/saas/web-frontend/build_from_dev_image.version \
1173+
all_in_one_image.version
1174+
1175+
if git diff-index --quiet HEAD --; then
1176+
echo "No changes detected — skipping commit."
1177+
exit 0
1178+
fi
1179+
1180+
COMMIT_MSG="Automatic core image bump:
1181+
- backend: ${BACKEND_IMAGE}
1182+
- web-frontend: ${WEB_IMAGE}
1183+
- all-in-one: ${ALL_IN_ONE_IMAGE}"
1184+
1185+
git commit -m "$COMMIT_MSG"
1186+
git push origin develop
1187+
1188+
echo "✅ Successfully pushed updates to baserow-saas."

0 commit comments

Comments
 (0)