Github Action to deploy Docker Image from Github Packages

I am coming from Heroku and want to get used to Docker and learn more about DevOps. So I informed myself about Github Actions and Github Packages.

Now I am searching for a starting point for my problem as I want to deploy via commit to a Digital Ocean Dropplet.

I have found the doctl lib. and some another question which unfortunately is using digital ocean registry.

If someone could share the actions.yml file for me, this would help me a lot.


Submit an answer

This textbox defaults to using Markdown to format your answer.

You can type !ref in this text area to quickly search our full set of tutorials, documentation & marketplace offerings and insert the link!

Sign In or Sign Up to Answer

These answers are provided by our Community. If you find them useful, show some love by clicking the heart. If you run into issues leave a comment, or add your own answer to help others.

Want to learn more? Join the DigitalOcean Community!

Join our DigitalOcean community of over a million developers for free! Get help and share knowledge in Q&A, subscribe to topics of interest, and get courses and tools that will help you grow as a developer and scale your project or business.

Try replacing password with SSH keys as outlined here:

Unfortunately I got stuck by the ssh handshake as I try to provide the credentials instead of a key.

2020/12/*** 13:30:13 ssh: handshake failed: ssh: unable to authenticate, attempted methods [none password], no supported methods remain

    name: Deploy to Digital Ocean Droplet
    runs-on: ubuntu-latest
    needs: push_to_github_container_registry

      - name: Deploy to Digital Ocean droplet via SSH action
        uses: appleboy/ssh-action@v0.1.3
          HOST: ${{ secrets.HOST }}
          USERNAME: ${{ secrets.USERNAME }}
          PASSWORD: ${{ secrets.PASSWORD }}
          PORT: ${{ secrets.PORT }}
          script: |
            # Stop running container
            docker stop ${{ github.repository_owner }}

            # Remove old container
            docker rm ${{ github.repository_owner }}

            # Login to Github Container Registry
            docker login -u ${{ github.repository_owner }} -p ${{ secrets.CR_PAT }}

            # Pull the Docker Image 
            docker pull${{ github.repository }}:latest

            # Run a new container from a new image
            docker run -d \
            --restart always \
            --env-file .env \
            -p 8000:8080 \
            --name $(echo $${{ github.repository }})

I successfully pushed my image to Github Container Registry with the following workflow

name: GHCR-DigitalOcean

  # Trigger the workflow on push
      - main

    name: Push to GHCR -> DigitlOcean
    runs-on: ubuntu-latest

      # Checkout the Repository
      - name: Checking out the repository
        uses: actions/checkout@v2

      # Setting up Docker Builder
      - name: Set up Docker Builder
        uses: docker/setup-buildx-action@v1

      # Set Github Access Token with "write:packages" scope for Github Container Registry.
      # Then go to repository setings and add the copied token as a secret called "CR_PAT"
      - name: Log into GitHub Container Registry
        uses: docker/login-action@v1
          username: ${{ github.repository_owner }}
          password: ${{ secrets.CR_PAT }}

      # Push to Github Container Registry
      - name: Push to Github Container Registry
        uses: docker/build-push-action@v2
          context: .
          version: latest
          file: dockerfile
          push: true
          tags:${{ github.repository }}:latest