From fa2841ff5b5feee75f7e4d9aaaa0db8bdfa28c48 Mon Sep 17 00:00:00 2001 From: vvisionnn Date: Tue, 1 Mar 2022 14:39:17 +0000 Subject: [PATCH] update docker actions --- .github/workflows/docker-release.yml | 52 ++++++++++++++++++++++++++++ .github/workflows/docker.yml | 52 ---------------------------- Dockerfile | 3 +- 3 files changed, 53 insertions(+), 54 deletions(-) create mode 100644 .github/workflows/docker-release.yml delete mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker-release.yml b/.github/workflows/docker-release.yml new file mode 100644 index 00000000..ce7ea9fe --- /dev/null +++ b/.github/workflows/docker-release.yml @@ -0,0 +1,52 @@ +name: Build and push docker image + +on: + push: + tags: + - 3.* # on push releast with tag 3.* + workflow_dispatch: # on button click + +jobs: + docker-build: + runs-on: ubuntu-latest + steps: + - name: Checkout + uses: actions/checkout@v2 + with: + clean: false + submodules: "recursive" + - name: Setup Environments + id: envs + run: | + CLOUDREVE_LATEST_TAG=$(git tag -l --sort=-creatordate | head -n 1) + DOCKER_IMAGE="cloudreve/cloudreve" + + echo "RELEASE_VERSION=${GITHUB_REF#refs/*/}" + TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${CLOUDREVE_LATEST_TAG}" + + echo "CLOUDREVE_LATEST_TAG:${CLOUDREVE_LATEST_TAG}" + echo ::set-output name=tags::${TAGS} + # - name: Setup QEMU Emulator + # uses: docker/setup-qemu-action@master + # with: + # platforms: all + # - name: Setup Docker Buildx Command + # id: buildx + # uses: docker/setup-buildx-action@master + # - name: Login to Dockerhub + # uses: docker/login-action@v1 + # with: + # username: ${{ secrets.DOCKERHUB_USERNAME }} + # password: ${{ secrets.DOCKERHUB_PASSWORD }} + # - name: Build Docker Image and Push + # id: docker_build + # uses: docker/build-push-action@v2 + # with: + # push: true + # builder: ${{ steps.buildx.outputs.name }} + # context: . + # file: ./Dockerfile + # platforms: linux/amd64,linux/arm64,linux/arm/v7 + # tags: ${{ steps.envs.outputs.tags }} + # - name: Image Digest + # run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml deleted file mode 100644 index abaf64b2..00000000 --- a/.github/workflows/docker.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Build and push docker image - -on: - push: - tags: - - 3.* # on push releast with tag 3.* - branches: - - master # every push on `master` branch - workflow_dispatch: # on button click - -jobs: - docker-build: - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v2 - with: - clean: false - submodules: "recursive" - - name: Setup Environments - id: envs - run: | - CLOUDREVE_LATEST_VERSION=$(git tag -l --sort=-creatordate | head -n 1) - DOCKER_IMAGE="cloudreve/cloudreve" - TAGS="${DOCKER_IMAGE}:latest,${DOCKER_IMAGE}:${CLOUDREVE_LATEST_VERSION}" - - echo "CLOUDREVE_LATEST_VERSION:${CLOUDREVE_LATEST_VERSION}" - echo ::set-output name=tags::${TAGS} - - name: Setup QEMU Emulator - uses: docker/setup-qemu-action@master - with: - platforms: all - - name: Setup Docker Buildx Command - id: buildx - uses: docker/setup-buildx-action@master - - name: Login to Dockerhub - uses: docker/login-action@v1 - with: - username: ${{ secrets.DOCKERHUB_USERNAME }} - password: ${{ secrets.DOCKERHUB_PASSWORD }} - - name: Build Docker Image and Push - id: docker_build - uses: docker/build-push-action@v2 - with: - push: true - builder: ${{ steps.buildx.outputs.name }} - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64,linux/arm/v7 - tags: ${{ steps.envs.outputs.tags }} - - name: Image Digest - run: echo ${{ steps.docker_build.outputs.digest }} diff --git a/Dockerfile b/Dockerfile index 6d2a3555..0dffb5c1 100644 --- a/Dockerfile +++ b/Dockerfile @@ -16,8 +16,7 @@ RUN cd ./Cloudreve/assets \ RUN cd ./Cloudreve \ && go get github.com/rakyll/statik \ && statik -src=assets/build/ -include=*.html,*.js,*.json,*.css,*.png,*.svg,*.ico -f \ - && tag_name=$(git describe --tags --abbrev=0) \ - && git checkout ${tag_name} \ + && tag_name=$(git describe --tags) \ && export COMMIT_SHA=$(git rev-parse --short HEAD) \ && go build -a -o cloudreve -ldflags " -X 'github.com/HFO4/cloudreve/pkg/conf.BackendVersion=$tag_name' -X 'github.com/HFO4/cloudreve/pkg/conf.LastCommit=$COMMIT_SHA'"