Skip to content

Publish on DockerHub

TimoBbz edited this page Jan 6, 2022 · 1 revision

Overview of the job

Login to Docker Hub and get informations

To connect to a Docker repository, you need login with credentials. It issues a token that is automatically saved then provided for the upcoming docker calls. This is achieved by the login step.

- name: Log in to Docker Hub
  uses: docker/login-action@f054a8b539a109f9f41c372932f1ae047eff08c9
  with:
    username: ${{ secrets.DOCKER_USERNAME }}
    password: ${{ secrets.DOCKER_PASSWORD }}

The following step is used to fetch/generate the useful informations. It fetch them from Dockerhub and stores them in the steps.meta.outputs variable for a future use.

Get Dockerfiles from checkout

To build a Docker image, a Dockerfile is needed. Each image corresponds to a .jar file, so several Dockerfiles must be fetched. The step used is the same as in the CI Build section.

Download and unzip artefacts

The download step is the same as in the CI Release section The unzip step simply calls the unzip shell command.

- name: Unzip artefacts
  run: |
    unzip RiseClipse.zip -d ${{ github.workspace }}
    ls ${{ github.workspace }}
    unzip RiseClipse.zip -d /

Build the images

The image is then builded and pushed on Dockerhub with a single action, that is used for every image.

- name: Build and push Docker image Validator SCL CLI
  uses: docker/build-push-action@v2
  with:
    context: ${{ github.workspace }}/riseclipse-validator-scl2003
    push: true
    tags: ${{ steps.meta.outputs.tags }}
    labels: ${{ steps.meta.outputs.labels }}

Job customization