Closed tijcolem closed 1 year ago
We are going to move the boptest-service branch into a dedicated repository. It might make sense to hold this merge until that happens. @dhblum
@kbenne Is this PR still relevant or can it be closed, given https://github.com/NREL/boptest-service?
Thank you!
This PR adds a GitHub Action to build, test and publish the boptest containers to Github packages container registry.
I tested this on my fork and the pushes to GitHub packages work well. I also included functionality (currently commented out) that can push to Docker Hub if desired. In order to push to Github packages you will need to create a new token that has write privileges to packages and create a secret in the repo called GH_REGISTRY and assign the value of the token to this. I put some more details for each step below.
1 ) To create the token for GitHub Actions to publish docker containers to the package registry, an admin will need to create a token scoped to write access for packages. And admin in the repo can create this by clicking on your profile Icon -> Settings -> Developer Settings -> Personal access tokens -> Generate new token. The token requires write:packages only (see screen grab for reference). Save the token for the next step
2 ) You will need to create a new repo secret called GH_REGISTRY with the value of the token received from the previous step. This allows GitHub actions to authenticate to push to packages. To create the repo secret go to the repo home page (e.g. https://github.com/ibpsa/project1-boptest) and click Settings -> Secrets -> Actions -> New repository secret.
Name=GH_REGISTRY Value=Token from previous step
Once 1 & 2 are done, Github can push containers to packages. The packages in Github are within the organizational level. For example, on my forked version the example boptest containers are accessible under:
https://github.com/tijcolem?tab=packages
You can control the visibility (public, private) in each package name by clicking the package name -> Package settings.
On the first build it will be defaulted to private, so if you want these packages public you will need to change the visibility for each package name once.
The logic of this script to is build and test the containers when there is a Push, Tag or Pull Request to the boptest-service branch. A push to boptest-service branch will build, test and publish container images with "develop" as the tag name. A tag that is pushed containing the words "-service" will build, test and publish with docker images with the tag name. For example, a tag that is pushed called "v0.3.0-service" will build and publish containers with the following names
boptest-web:v0.2.3-service
andboptest-worker:v0.2.3-service
. Below is a table showing the actions for each event.Just a note that this is only for boptest-service branch. A push or PR to master branch for example, this CI Action will not run.