Last active
January 10, 2020 01:07
-
-
Save int128/18f5d20a1d860b2c37d3aa2ae681bc3e to your computer and use it in GitHub Desktop.
GitHub Actions to build and push a Docker image to GitHub Packages Registry
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build and push the Docker image | |
on: | |
push: | |
paths: | |
- docker/** | |
jobs: | |
build: | |
runs-on: ubuntu-18.04 | |
steps: | |
- uses: actions/checkout@v2 | |
- run: make -C docker release | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
#if: github.event.push.ref == 'refs/heads/master' |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
FROM alpine:3.11 | |
ARG VERSION | |
#TODO: add steps |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
VERSION := v1.0.0 | |
IMAGE_NAME := docker.pkg.github.com/octocat/example/example | |
IMAGE_TAG := $(VERSION) | |
GITHUB_USERNAME := octocat | |
.PHONE: build | |
build: Dockerfile | |
docker pull $(IMAGE_NAME):$(IMAGE_TAG) | |
docker build -t $(IMAGE_NAME):$(IMAGE_TAG) --build-arg VERSION=$(VERSION) . | |
docker run --rm $(IMAGE_NAME):$(IMAGE_TAG) --version | |
.PHONE: release | |
release: build | |
docker login docker.pkg.github.com --username $(GITHUB_USERNAME) --password $(GITHUB_TOKEN) | |
docker push $(IMAGE_NAME):$(IMAGE_TAG) | |
.PHONY: clean | |
clean: | |
docker rmi $(IMAGE_NAME):$(IMAGE_TAG) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment