From 29acb8eaeec4ad61d11a47ca8afbc51064d594a6 Mon Sep 17 00:00:00 2001 From: Shohei Ueda <30958501+peaceiris@users.noreply.github.com> Date: Thu, 9 Jul 2020 05:33:46 +0900 Subject: [PATCH] ci: push dev docker image to packages (#384) --- .github/workflows/dev-image.yml | 6 ++++++ Makefile | 16 +++++++++++++--- 2 files changed, 19 insertions(+), 3 deletions(-) diff --git a/.github/workflows/dev-image.yml b/.github/workflows/dev-image.yml index 9ea4f9bcf..27bfd7b1c 100644 --- a/.github/workflows/dev-image.yml +++ b/.github/workflows/dev-image.yml @@ -32,6 +32,12 @@ jobs: if: contains(github.event.head_commit.message, '[skip ci]') == false steps: - uses: actions/checkout@v2.3.1 + - name: Login to Packages + run: echo '${{ secrets.GITHUB_TOKEN }}' | docker login 'docker.pkg.github.com' -u 'peaceiris' --password-stdin + - run: make pull + if: github.event_name == 'pull_request' - run: make build - run: make cirun cmd="npm ci" - run: make ciall + - run: make push + if: github.ref == 'refs/heads/master' diff --git a/Makefile b/Makefile index 90f1fd6bf..7af7624bf 100644 --- a/Makefile +++ b/Makefile @@ -1,15 +1,25 @@ cmd := "bash" msg := "" -IMAGE_NAME := actions_github_pages_dev:latest +IMAGE_NAME := docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest NODE_VERSION := $(shell cat ./.nvmrc) -DOCKER_BUILD := docker build . -t $(IMAGE_NAME) --build-arg NODE_VERSION=$(NODE_VERSION) DOCKER_RUN := docker run --rm -i -t -v ${PWD}:/repo -v ~/.gitconfig:/root/.gitconfig $(IMAGE_NAME) DOCKER_RUN_CI := docker run --rm -v ${PWD}:/repo $(IMAGE_NAME) .PHONY: build build: - $(DOCKER_BUILD) + docker build . \ + --build-arg NODE_VERSION=$(NODE_VERSION) \ + --cache-from=${IMAGE_NAME} \ + -t $(IMAGE_NAME) + +.PHONY: pull +pull: + docker pull ${IMAGE_NAME} + +.PHONY: push +push: + docker push ${IMAGE_NAME} .PHONY: run run: