Github Actions
About a month ago, GitHub made GitHub Actions generally available. Earlier in the year, they also made the GitHub Package Repositry generally available. This was the exact combination that I needed for a couple personal projects, so I immediately migrated my builds from CircleCI.
There are a ton of blog posts and tutorials about setting up this kind of stuff, so after a couple
days experimenting and googleing, here is my ci.yml
:
name: Build, Tag, and Publish Docker image
env:
REGISTRY: docker.pkg.github.com
IMAGE: auth
on:
push:
branches:
- master
jobs:
build:
name: Build, Tag, and Publish Docker image
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v1
- name: Generate VERSION
run: echo "::set-env name=VERSION::$(git describe --tags --always --dirty)"
- name: Build IMAGE
run: docker build -t ${IMAGE} .
- name: Tag IMAGE:VERSION and IMAGE:latest
run: |
docker tag ${IMAGE} ${REGISTRY}/$/${IMAGE}:${VERSION}
docker tag ${IMAGE} ${REGISTRY}/$/${IMAGE}:latest
- name: Login to Registry
run: echo $ | docker login ${REGISTRY} -u $ --password-stdin
- name: Publish IMAGE:VERSION and IMAGE:latest
run: |
docker push ${REGISTRY}/$/${IMAGE}:${VERSION}
docker push ${REGISTRY}/$/${IMAGE}:latest
Now, every time I push to master, the code is checked out, a docker image is created, and saved to the Package Repository.