From 05e490aa91ed689192b428e606dec4b9c46124ac Mon Sep 17 00:00:00 2001 From: Manav Rathi Date: Sat, 22 Jun 2024 18:44:21 +0530 Subject: [PATCH] [web] Build the staging/web branch when deploying if it exists This allows us to temporarily deploy arbitrary branches to staging by pushing to a staging/web branch. Removing that branch reverts to the existing and default behaviour of deploying main. Untested (need to deploy and trigger) Refs: - https://github.com/NLnetLabs/krill/commit/942f6a9fe9b43c2ddcd5adec261964359133d8e0 - https://docs.github.com/en/actions/learn-github-actions/contexts#steps-context - https://stackoverflow.com/questions/57819539/github-actions-how-to-share-a-calculated-value-between-job-steps --- .github/workflows/web-deploy-staging.yml | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/.github/workflows/web-deploy-staging.yml b/.github/workflows/web-deploy-staging.yml index ca3a6142b2..014afed10f 100644 --- a/.github/workflows/web-deploy-staging.yml +++ b/.github/workflows/web-deploy-staging.yml @@ -1,5 +1,7 @@ name: "Deploy staging (web)" +# Builds the "staging/web" branch if it exists, "main" otherwise. + on: schedule: # Run everyday at ~3:00 PM IST @@ -18,9 +20,19 @@ jobs: working-directory: web steps: - - name: Checkout code + - name: Determine branch to build + id: select-branch + run: | + if git ls-remote --exit-code --heads https://github.com/ente-io/ente refs/heads/staging/web; then + echo "branch=staging/web" >> $GITHUB_OUTPUT + else + echo "branch=main" >> $GITHUB_OUTPUT + fi + + - name: Checkout ${{ steps.select-branch.outputs.branch }} uses: actions/checkout@v4 with: + ref: ${{ steps.select-branch.outputs.branch }} submodules: recursive - name: Setup node and enable yarn caching