crm# 241111-003762 rims user orcid, institution sync #46
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: Docker | |
| # initially we would us on: [release] as well, the problem is that | |
| # the code in clowder would not know what branch the code is in, | |
| # and would not set the right version flags. | |
| # This will run when: | |
| # - when new code is pushed to master/develop to push the tags | |
| # latest and develop | |
| # - when a pull request is created and updated to make sure the | |
| # Dockerfile is still valid. | |
| # To be able to push to dockerhub, this execpts the following | |
| # secrets to be set in the project: | |
| # - DOCKERHUB_USERNAME : username that can push to the org | |
| # - DOCKERHUB_PASSWORD : password asscoaited with the username | |
| on: | |
| push: | |
| branches: | |
| - rcc | |
| tags: | |
| - pitschi* | |
| # Certain actions will only run when this is the master repo. | |
| env: | |
| MASTER_REPO: UQ-RCC/clowder | |
| DOCKERHUB_ORG: uqrcc | |
| jobs: | |
| docker: | |
| runs-on: ubuntu-latest | |
| strategy: | |
| fail-fast: true | |
| matrix: | |
| name: | |
| - clowder | |
| - mongo-init | |
| - monitor | |
| - elasticsearch | |
| include: | |
| - name: clowder | |
| FOLDER: "." | |
| IMAGE: clowder | |
| README: README.md | |
| - name: mongo-init | |
| FOLDER: scripts/mongo-init | |
| IMAGE: mongo-init | |
| README: "" | |
| - name: monitor | |
| FOLDER: scripts/monitor | |
| IMAGE: monitor | |
| README: "" | |
| - name: elasticsearch | |
| FOLDER: scripts/elasticsearch | |
| IMAGE: elasticsearch | |
| README: "" | |
| steps: | |
| - uses: actions/checkout@v2 | |
| # calculate some variables that are used later | |
| - name: github branch | |
| run: | | |
| if [ "${{ github.event.release.target_commitish }}" != "" ]; then | |
| BRANCH="${{ github.event.release.target_commitish }}" | |
| else | |
| BRANCH=${GITHUB_REF##*/} | |
| fi | |
| echo "GITHUB_BRANCH=${BRANCH}" >> $GITHUB_ENV | |
| if [ "$BRANCH" == "master" ]; then | |
| version="$(awk '/version = / { print $4 }' project/Build.scala | sed 's/"//g')" | |
| tags="latest" | |
| oldversion="" | |
| while [ "${oldversion}" != "${version}" ]; do | |
| oldversion="${version}" | |
| tags="${tags},${version}" | |
| version=${version%.*} | |
| done | |
| echo "CLOWDER_VERSION=$(awk '/version = / { print $4 }' project/Build.scala | sed 's/"//g')" >> $GITHUB_ENV | |
| echo "CLOWDER_TAGS=${tags}" >> $GITHUB_ENV | |
| elif [ "$BRANCH" == "develop" ]; then | |
| echo "CLOWDER_VERSION=develop" >> $GITHUB_ENV | |
| echo "CLOWDER_TAGS=develop" >> $GITHUB_ENV | |
| else | |
| echo "CLOWDER_VERSION=${{ github.event.release.tag_name }}" >> $GITHUB_ENV | |
| echo "CLOWDER_TAGS=" >> $GITHUB_ENV | |
| fi | |
| # build the docker image, this will always run to make sure | |
| # the Dockerfile still works. | |
| - name: Build image | |
| uses: elgohr/Publish-Docker-Github-Action@2.22 | |
| env: | |
| BRANCH: ${{ env.GITHUB_BRANCH }} | |
| VERSION: ${{ env.CLOWDER_VERSION }} | |
| BUILDNUMBER: ${{ github.run_number }} | |
| GITSHA1: ${{ github.sha }} | |
| with: | |
| registry: docker.pkg.github.com | |
| name: ${{ github.repository_owner }}/${{ github.event.repository.name }}/${{ matrix.IMAGE }} | |
| username: ${{ github.actor }} | |
| password: ${{ secrets.GITHUB_TOKEN }} | |
| context: ${{ matrix.FOLDER }} | |
| tags: ${{ env.GITHUB_BRANCH }} | |
| buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
| no_push: true | |
| # this will publish to github container registry | |
| # - name: Publish to GitHub | |
| # if: github.event_name != 'pull_request' && github.repository == env.MASTER_REPO | |
| # uses: elgohr/Publish-Docker-Github-Action@2.22 | |
| # env: | |
| # BRANCH: ${{ env.GITHUB_BRANCH }} | |
| # VERSION: ${{ env.CLOWDER_VERSION }} | |
| # BUILDNUMBER: ${{ github.run_number }} | |
| # GITSHA1: ${{ github.sha }} | |
| # with: | |
| # registry: ghcr.io | |
| # name: ${{ github.repository_owner }}/${{ matrix.IMAGE }} | |
| # username: ${{ secrets.GHCR_USERNAME }} | |
| # password: ${{ secrets.GHCR_PASSWORD }} | |
| # context: ${{ matrix.FOLDER }} | |
| # tags: "${{ env.CLOWDER_TAGS }}" | |
| # buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
| # this will publish to the clowder dockerhub repo | |
| - name: Publish to Docker Hub | |
| if: github.event_name != 'pull_request' && github.repository == env.MASTER_REPO | |
| uses: elgohr/Publish-Docker-Github-Action@2.22 | |
| env: | |
| BRANCH: ${{ env.GITHUB_BRANCH }} | |
| VERSION: ${{ env.CLOWDER_VERSION }} | |
| BUILDNUMBER: ${{ github.run_number }} | |
| GITSHA1: ${{ github.sha }} | |
| with: | |
| name: ${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }} | |
| username: ${{ secrets.DOCKERHUB_USERNAME }} | |
| password: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| context: ${{ matrix.FOLDER }} | |
| tags: ${{ env.GITHUB_BRANCH }} | |
| buildargs: BRANCH,VERSION,BUILDNUMBER,GITSHA1 | |
| # this will update the README of the dockerhub repo | |
| - name: check file | |
| id: filecheck | |
| run: | | |
| if [ "${{ matrix.README }}" != "" ]; then | |
| if [ -e "${{ matrix.README }}" ]; then | |
| echo "##[set-output name=readme;]${{ matrix.README }}" | |
| else | |
| echo "##[set-output name=readme;]" | |
| fi | |
| else | |
| if [ -e "${{ matrix.FOLDER }}/README.md" ]; then | |
| echo "##[set-output name=readme;]${{ matrix.FOLDER }}/README.md" | |
| else | |
| echo "##[set-output name=readme;]" | |
| fi | |
| fi | |
| - name: Docker Hub Description | |
| if: github.event_name == 'push' && github.repository == env.MASTER_REPO && env.BRANCH == 'master' && steps.filecheck.outputs.readme != '' | |
| uses: peter-evans/dockerhub-description@v2 | |
| env: | |
| DOCKERHUB_USERNAME: ${{ secrets.DOCKERHUB_USERNAME }} | |
| DOCKERHUB_PASSWORD: ${{ secrets.DOCKERHUB_PASSWORD }} | |
| DOCKERHUB_REPOSITORY: ${{ env.DOCKERHUB_ORG }}/${{ matrix.IMAGE }} | |
| README_FILEPATH: ${{ steps.filecheck.outputs.readme }} |