aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorcrupest <crupest@outlook.com>2020-11-04 18:45:44 +0800
committercrupest <crupest@outlook.com>2020-11-04 18:45:44 +0800
commit0404e4a3f7a52c1af55dfa0a8228e508e0541b96 (patch)
tree6a4939ec7cfa56f35729b44bb49de3dbd67f5f26
parentf54b914b4573530e89e9ad97dadb37024eedc91e (diff)
downloadtimeline-0404e4a3f7a52c1af55dfa0a8228e508e0541b96.tar.gz
timeline-0404e4a3f7a52c1af55dfa0a8228e508e0541b96.tar.bz2
timeline-0404e4a3f7a52c1af55dfa0a8228e508e0541b96.zip
build: Fix ci and docker file.
-rw-r--r--.github/workflows/cd-version.yaml40
-rw-r--r--.github/workflows/cd.yaml22
-rw-r--r--Dockerfile2
3 files changed, 55 insertions, 9 deletions
diff --git a/.github/workflows/cd-version.yaml b/.github/workflows/cd-version.yaml
index a15acd2a..1479e0e6 100644
--- a/.github/workflows/cd-version.yaml
+++ b/.github/workflows/cd-version.yaml
@@ -13,10 +13,42 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Build And Push to Docker Hub
- uses: docker/build-push-action@v1
+ -
+ name: Prepare
+ id: prep
+ run: |
+ DOCKER_IMAGE=crupest/timeline
+ VERSION=edge
+ if [[ $GITHUB_REF == refs/tags/* ]]; then
+ VERSION=${GITHUB_REF#refs/tags/}
+ elif [[ $GITHUB_REF == refs/heads/* ]]; then
+ VERSION=$(echo ${GITHUB_REF#refs/heads/} | sed -r 's#/+#-#g')
+ elif [[ $GITHUB_REF == refs/pull/* ]]; then
+ VERSION=pr-${{ github.event.number }}
+ fi
+ TAGS="${DOCKER_IMAGE}:${VERSION}"
+ echo ::set-output name=version::${VERSION}
+ echo ::set-output name=tags::${TAGS}
+ echo ::set-output name=created::$(date -u +'%Y-%m-%dT%H:%M:%SZ')
+
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- repository: crupest/timeline
- tag_with_ref: true
+
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ tags: ${{ steps.prep.outputs.tags }}
+
+ - name: Image digest
+ run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/.github/workflows/cd.yaml b/.github/workflows/cd.yaml
index 4ddfd6d1..a9ebddd8 100644
--- a/.github/workflows/cd.yaml
+++ b/.github/workflows/cd.yaml
@@ -12,10 +12,24 @@ jobs:
steps:
- uses: actions/checkout@v2
- - name: Build And Push to Docker Hub
- uses: docker/build-push-action@v1
+ - name: Set up QEMU
+ uses: docker/setup-qemu-action@v1
+
+ - name: Set up Docker Buildx
+ uses: docker/setup-buildx-action@v1
+
+ - name: Login to DockerHub
+ uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PASSWORD }}
- repository: crupest/timeline
- tags: latest
+
+ - name: Build and push
+ id: docker_build
+ uses: docker/build-push-action@v2
+ with:
+ push: true
+ tags: crupest/timeline:latest
+
+ - name: Image digest
+ run: echo ${{ steps.docker_build.outputs.digest }}
diff --git a/Dockerfile b/Dockerfile
index b9b958b0..b602cba0 100644
--- a/Dockerfile
+++ b/Dockerfile
@@ -1,7 +1,7 @@
FROM node:latest AS front-build
WORKDIR /timeline-app
COPY FrontEnd .
-RUN yarn build
+RUN yarn && yarn build
FROM mcr.microsoft.com/dotnet/core/sdk:3.1 AS back-build
WORKDIR /timeline-app