mirror of
https://github.com/peaceiris/actions-gh-pages.git
synced 2025-07-15 06:33:17 +08:00
ci: Add docker-compose.yml (#406)
This commit is contained in:
parent
09b03c0bb1
commit
a2712f7b92
10
.github/workflows/dev-image.yml
vendored
10
.github/workflows/dev-image.yml
vendored
@ -10,6 +10,7 @@ on:
|
|||||||
- '.nvmrc'
|
- '.nvmrc'
|
||||||
- 'Dockerfile'
|
- 'Dockerfile'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
|
- 'docker-compose.yml'
|
||||||
pull_request:
|
pull_request:
|
||||||
types:
|
types:
|
||||||
- opened
|
- opened
|
||||||
@ -20,6 +21,7 @@ on:
|
|||||||
- '.nvmrc'
|
- '.nvmrc'
|
||||||
- 'Dockerfile'
|
- 'Dockerfile'
|
||||||
- 'Makefile'
|
- 'Makefile'
|
||||||
|
- 'docker-compose.yml'
|
||||||
|
|
||||||
jobs:
|
jobs:
|
||||||
skipci:
|
skipci:
|
||||||
@ -34,10 +36,10 @@ jobs:
|
|||||||
- uses: actions/checkout@v2.3.1
|
- uses: actions/checkout@v2.3.1
|
||||||
- name: Login to Packages
|
- name: Login to Packages
|
||||||
run: echo '${{ secrets.GITHUB_TOKEN }}' | docker login 'docker.pkg.github.com' -u 'peaceiris' --password-stdin
|
run: echo '${{ secrets.GITHUB_TOKEN }}' | docker login 'docker.pkg.github.com' -u 'peaceiris' --password-stdin
|
||||||
- run: make pull
|
- run: docker-compose pull --quiet
|
||||||
if: github.event_name == 'pull_request'
|
if: github.event_name == 'pull_request'
|
||||||
- run: make build
|
- run: make build
|
||||||
- run: make cirun cmd="npm ci"
|
- run: make ci
|
||||||
- run: make ciall
|
- run: make all
|
||||||
- run: make push
|
- run: docker-compose push
|
||||||
if: github.ref == 'refs/heads/main'
|
if: github.ref == 'refs/heads/main'
|
||||||
|
38
Makefile
38
Makefile
@ -1,46 +1,22 @@
|
|||||||
cmd := "bash"
|
|
||||||
msg := ""
|
|
||||||
IMAGE_NAME := docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest
|
IMAGE_NAME := docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest
|
||||||
NODE_VERSION := $(shell cat ./.nvmrc)
|
NODE_VERSION := $(shell cat ./.nvmrc)
|
||||||
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
|
.PHONY: build
|
||||||
build:
|
build:
|
||||||
docker build . \
|
docker-compose build --build-arg NODE_VERSION=$(NODE_VERSION)
|
||||||
--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
|
.PHONY: run
|
||||||
run:
|
run:
|
||||||
$(DOCKER_RUN) $(cmd)
|
docker-compose run --rm dev bash
|
||||||
|
|
||||||
.PHONY: cirun
|
.PHONY: ci
|
||||||
cirun:
|
ci:
|
||||||
$(DOCKER_RUN_CI) $(cmd)
|
docker-compose run --rm -T dev npm ci
|
||||||
|
|
||||||
.PHONY: test
|
.PHONY: test
|
||||||
test:
|
test:
|
||||||
$(DOCKER_RUN) npm test
|
docker-compose run --rm -T dev npm test
|
||||||
|
|
||||||
.PHONY: commit
|
|
||||||
commit:
|
|
||||||
$(DOCKER_RUN) git commit -m "$(msg)"
|
|
||||||
|
|
||||||
.PHONY: all
|
.PHONY: all
|
||||||
all:
|
all:
|
||||||
$(DOCKER_RUN) npm run all
|
docker-compose run --rm -T dev npm run all
|
||||||
|
|
||||||
.PHONY: ciall
|
|
||||||
ciall:
|
|
||||||
$(DOCKER_RUN_CI) npm run all
|
|
||||||
|
16
docker-compose.yml
Normal file
16
docker-compose.yml
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
version: '3.2'
|
||||||
|
|
||||||
|
services:
|
||||||
|
dev:
|
||||||
|
image: 'docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest'
|
||||||
|
build:
|
||||||
|
context: .
|
||||||
|
cache_from:
|
||||||
|
- 'docker.pkg.github.com/peaceiris/actions-gh-pages/dev:latest'
|
||||||
|
container_name: peaceiris_actions_github_pages
|
||||||
|
volumes:
|
||||||
|
- ${PWD}:/repo
|
||||||
|
stdin_open: true
|
||||||
|
tty: true
|
||||||
|
command:
|
||||||
|
- bash
|
Loading…
x
Reference in New Issue
Block a user