[FOLIO-3270] Handle default branch name in NPM Workflows step SonarCloud Created: 26/Aug/21 Updated: 30/Aug/21 Resolved: 27/Aug/21 |
|
| Status: | Closed |
| Project: | FOLIO |
| Components: | None |
| Affects versions: | None |
| Fix versions: | None |
| Type: | Task | Priority: | TBD |
| Reporter: | David Crossley | Assignee: | Ankita Sen |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original estimate: | Not Specified | ||
| Issue links: |
|
||||||||||||
| Sprint: | DevOps Sprint 121 | ||||||||||||
| Development Team: | FOLIO DevOps | ||||||||||||
| Description |
|
In the "SonarCloud" step of the GitHub Actions workflows for NPM, there is a hardcoded "master" branch name. This will need to handle either "main" or "master" to enable repositories to be transitioned to the new name. |
| Comments |
| Comment by Ankita Sen [ 26/Aug/21 ] |
|
David Crossley - The $default-branch variable doesn't work and the best way I found after trying several ways was to add another environment variable called DEFAULT_VARIABLE and for the following repositories set it to master
The Github workflow template has also been updated. |
| Comment by Ankita Sen [ 26/Aug/21 ] |
|
The workflow has been to modified to remove the hardcoded 'master' instead configuring a environment variable DEFAULT_BRANCh to either 'master' or 'main' |
| Comment by David Crossley [ 27/Aug/21 ] |
|
That technique seems to be sub-optimal. It now means that when repos want to later switch to "main" as their default branch, then there will be many workflows to be modified. Especially if we need to switch them all at the same time. (About 180 frontend and backend repos with 2 or more each.) My net search found a potential solution today. I do not profess to be expert, but it seems to work in my minimal test. You would know better – perhaps there are specific situations where it is not sufficient. It is from https://stackoverflow.com/a/68414395 (thanks "antonmos") added recently last month. See https://github.com/folio-org/ga-test/actions/workflows/test-default-branch.yml |
| Comment by Ankita Sen [ 27/Aug/21 ] |
|
David Crossley - Thank you very much for this suggestion. It works. I am now updating all the repositories with this solution. |
| Comment by Ankita Sen [ 27/Aug/21 ] |
|
Updated all the workflows with the proposed solution by David Crossley. |
| Comment by David Crossley [ 27/Aug/21 ] |
|
That is fantastic. Thanks. |
| Comment by David Crossley [ 30/Aug/21 ] |
|
A reminder that the workflow-templates are not yet updated. |