heroku icon indicating copy to clipboard operation
heroku copied to clipboard

Pushing an existing Docker image

Open Happy-Ferret opened this issue 5 years ago • 3 comments

Curious. How would I go about pushing an image I've already built through the Docker CLI, in a previous build step?

My current workflow looks as follows:

    steps:
    - uses: actions/checkout@v1
    - name: Sign into Docker registry
      run: |
        docker login -u $DOCKER_USERNAME -p $DOCKER_PASSWORD $DOCKER_REGISTRY_URL
      env:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USER }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PW }}
        DOCKER_REGISTRY_URL: docker.pkg.github.com
    - name: Remove old Docker image
      run: |
        docker images -a 
        docker rmi --force 'latest'
    - name: Build Docker image
      run: | 
        cd WebApplication1Core
        docker images -a 
        docker build -t docker.pkg.github.com/ebsone/ci-test-mr/webapplication1corenew:latest -f WebApplication1Core/Dockerfile .
    - name: Push Docker image
      env:
        DOCKER_USERNAME: ${{ secrets.DOCKER_USER }}
        DOCKER_PASSWORD: ${{ secrets.DOCKER_PW }}
        DOCKER_REGISTRY_URL: docker.pkg.github.com
      run: |
        docker push docker.pkg.github.com/ebsone/ci-test-mr/webapplication1corenew:latest
    - name: Heroku Login
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:login
    - name: Heroku Tag
      run: |
        docker tag docker.pkg.github.com/ebsone/ci-test-mr/webapplication1corenew:latest registry.heroku.com/ci-test-mr/web
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
    - name: Heroku Push
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:push -a ci-test-mr registry.heroku.com/ci-test-mr/web
    - name: Heroku Release
      uses: actions/heroku@master
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}
      with:
        args: container:release -a ci-test-mr registry.heroku.com/ci-test-mr/web

This fails during the "Heroku Push" step.

Error message: No images to push

Happy-Ferret avatar Oct 21 '19 15:10 Happy-Ferret

Turns out the Heroku Action is no longer needed, as GitHub Actions now supports Heroku by default (just like it does Docker).

I therefore removed the Heroku Action dependency and the Heroku build steps, and created the following singular build step:

- name: Heroku Release
      run: |
        docker login --username=_ --password=$HEROKU_API_KEY registry.heroku.com
        docker tag docker.pkg.github.com/ebsone/ci-test-mr/webapplication1corenew:latest registry.heroku.com/ci-test-mr/web
        docker push registry.heroku.com/ci-test-mr/web
        heroku container:release web -a ci-test-mr
      env:
        HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }}

Happy-Ferret avatar Oct 28 '19 06:10 Happy-Ferret

@Happy-Ferret Hi, do you have a link about heroku being supported by default in github actions?

mathieug avatar Nov 21 '19 15:11 mathieug

@mathieug The code to generate the VMs is open source and the individual READMEs have a comprehensive list of tools installed: https://github.com/actions/virtual-environments/blob/master/images/linux/Ubuntu1604-README.md I hope that helps

hfaulds avatar Nov 22 '19 15:11 hfaulds