Implemented the following logic: there is a new stage Validation which checks at the beginning of each pipeline if the variable DBREQUIRED is either yes or no. All subsequent tasks no longer have the conditions in only or except but do the check for that value in an if statement of the script.
If this is working as expected, there will be one remaining validation: if the DB container exists but the DB is empty.
@danielspeicher do you want to do a quick review if the logic makes sense?
At the same time, what variable name should we use instead of FORCE_DB_UPDATE and what string should we expect in commit messages instead of [re-build-db]?
I tend to DB_UPDATE in both cases. It does not sound so hard without FORCE. Does the underscore cause a problem in the commit message? If so, the we can use [db-update].
DB_UPDATE was my favourite too until I realized this could be confused with the Drupal database update. What about PULL_DB instead? That probably better describes what's really going on?
Finally got this working by passing the resulting variable downstream to the following jobs with artifacts.reports.dotenv and now the DB will be pulled in either of these circumstances:
if branch is master
if commit message contains [PULL_DB]
if variable PULL_DB is set to yes
if the database container of the current project does not yet exist
if the table users_data doesn't exist in the database