[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:

- 942f6a9fe9
- 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
This commit is contained in:
Manav Rathi
2024-06-22 18:44:21 +05:30
parent 32757c3fb6
commit 05e490aa91

View File

@@ -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