Yesterday I moved the deployment for this site from a local script to GitHub actions. Overall it was a really pleasant experience because GitHub made it really easy to run scripts inside e.g. a Node.js environment, which I need to build the site.
One thing that was a bit tricky for me, was figuring out how to
git push to my Dokku server from GitHub Actions. I needed to authenticate GitHub Actions for SSH access to my Dokku server.
I ended up generating a new SSH key for GitHub Actions and saving the private key to my repository's secrets (find them in the repo settings) as
Then I added a few lines to my
name: CIon:push:branches: [master]jobs:build:runs-on: ubuntu-lateststeps:- uses: actions/checkout@v2- name: Setup Node.js environmentuses: firstname.lastname@example.org:node-version: 12.x- name: Install dependenciesrun: yarn- name: Build and deployrun: |git config --global user.email "email@example.com"git config --global user.name "GitHub actions"yarn build --env productiongit remote add dokku firstname.lastname@example.org:app-namegit add dist --forcegit commit -m "Deploy"git push dokku master -f
And that's all it took to get Github Actions authenticated with my Dokku server. I hope this was helpful to you, thanks for reading!