By nixn
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.
Thanks
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!
I successfully pushed my image to Github Container Registry with the following workflow
name: GHCR-DigitalOcean
on:
# Trigger the workflow on push
push:
branches:
- main
jobs:
push_to_registry:
name: Push to GHCR -> DigitlOcean
runs-on: ubuntu-latest
steps:
# 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"
# https://github.com/settings/tokens/new?scopes=repo,write:packages&description=Github+Container+Registry
- name: Log into GitHub Container Registry
uses: docker/login-action@v1
with:
registry: ghcr.io
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
with:
context: .
version: latest
file: dockerfile
push: true
tags: ghcr.io/${{ github.repository }}:latest
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
deploy_to_digital_ocean_dropplet:
name: Deploy to Digital Ocean Droplet
runs-on: ubuntu-latest
needs: push_to_github_container_registry
steps:
- name: Deploy to Digital Ocean droplet via SSH action
uses: appleboy/ssh-action@v0.1.3
with:
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 https://ghcr.io -u ${{ github.repository_owner }} -p ${{ secrets.CR_PAT }}
# Pull the Docker Image
docker pull ghcr.io/${{ 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 }})
Try replacing password with SSH keys as outlined here: https://link.medium.com/q6VrYwUOCmb
Get paid to write technical tutorials and select a tech-focused charity to receive a matching donation.
Full documentation for every DigitalOcean product.
The Wave has everything you need to know about building a business, from raising funding to marketing your product.
Stay up to date by signing up for DigitalOcean’s Infrastructure as a Newsletter.
New accounts only. By submitting your email you agree to our Privacy Policy
Scale up as you grow — whether you're running one virtual machine or ten thousand.
Sign up and get $200 in credit for your first 60 days with DigitalOcean.*
*This promotional offer applies to new accounts only.