8

I am implementing CICD pipeline with github actions. I want to publish the docker image to jfrog artifactory. Does anybody has any idea how to implement that?

Krzysztof Madej
  • 32,704
  • 10
  • 78
  • 107
urmila
  • 81
  • 1
  • 3
  • Does this answer your question? [New location of docker actions](https://stackoverflow.com/questions/58350578/new-location-of-docker-actions) – Edward Romero Sep 15 '20 at 04:10
  • Follow the steps in link provided on my first comment but change the docker github registry to the artifactory registry and you should be good to go – Edward Romero Sep 15 '20 at 04:11
  • want to use jfrog cli to publish image to jfrog artifactory with jfrog access token. I have generated token and used in github actions CI pipeline, but it throws error like '[Error] illegal base64 data at input byte 119' and later '[Error] invalid character 'e' looking for beginning of value' – urmila Sep 17 '20 at 04:33

5 Answers5

12

A complete sample with login, build and push to a jfrog artifactory.

This sample exepected a Dockerfile at the root of the repository, and secrets stored in GitHub Secrets.

jobs:
  build:
    runs-on: ubuntu-latest

    steps:
      - name: Checkout ️
        uses: actions/checkout@v2

      - name: Set up QEMU ️
        uses: docker/setup-qemu-action@v1

      - name: Set up Docker Buildx 
        uses: docker/setup-buildx-action@v1

      - name: Login to JFrog   
        uses: docker/login-action@v1
        with:
          registry: <your artifactory>.jfrog.io
          username: ${{ secrets.JFROG_USER_WRITER }}
          password: ${{ secrets.JFROG_PASSWORD_WRITER }}

      - name: Build and push 
        id: docker_build
        uses: docker/build-push-action@v2
        with:
          push: true
          tags: <your artifactory>.jfrog.io/<your image name>:latest
Quentin
  • 481
  • 6
  • 13
3

You should just be able to log into the registry without using the jfrog cli with docker login. F.e:

  - uses: actions/checkout@v2
      - name: Login to DockerHub Registry
        run: docker login -u ${{ secrets.REGISTRY_USERNAME }} -p ${{ secrets.REGISTRY_PASSWORD }} artifactory.<yourcompanyrepo>.com
mattrzr
  • 53
  • 1
  • 7
1

Using the docker-login github action, you could specify the registry.

F.e.

  • name: Login to GitHub Container Registry uses: docker/login-action@v1 with: registry: artifactory..com username: user password: pass
mattrzr
  • 53
  • 1
  • 7
0

An easier attitude would be using the JFrog CLI and the Setup JFrog CLI GitHub Action:

  1. In your local machine, configure and export your JFrog server:
# Interactively, create a new server
jfrog c add

# Create a server token. This token can be used as a secret in your workflow named: "JF_ARTIFACTORY_SECRET".
jfrog c export
  1. Run the Setup JFrog CLI GitHub Action:
- uses: jfrog/setup-jfrog-cli@v1
  env:
    JF_ARTIFACTORY: ${{ secrets.JF_ARTIFACTORY_SECRET }}
- run: |
    jfrog rt docker-push <image tag> <target repo>
    
    # Optional - publish build info to Artifactory
    jfrog rt bp

Read more about it:

yahavi
  • 5,149
  • 4
  • 23
  • 39
0

Based on the answer of @Quentin,

You might face an error while running Docker Buildx step saying:

Error response from daemon: manifest for not found: manifest unknown: The named manifest is not known to the registry

The solution for this problem is to run docker context create builders in a separate step then use the created builders within Docker Buildx step as following:

...

- name: Set up Docker Context for Buildx
  id: buildx-context
  run: |
    docker context create builders

- name: Set up Docker Buildx
  uses: docker/setup-buildx-action@v2
  with:
    version: latest
    endpoint: builders
...
ivey221
  • 95
  • 7