From 22b6d50e0aefb3da8d95c8756b3c1bc70f14a292 Mon Sep 17 00:00:00 2001 From: huanghs Date: Sat, 17 Aug 2024 17:22:11 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=96=B0=20.gitea/workflows/cache-npx?= =?UTF-8?q?.yml?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .gitea/workflows/cache-npx.yml | 49 +++++++++++++++++++++++++++++----- 1 file changed, 43 insertions(+), 6 deletions(-) diff --git a/.gitea/workflows/cache-npx.yml b/.gitea/workflows/cache-npx.yml index a58c105..8353f8c 100644 --- a/.gitea/workflows/cache-npx.yml +++ b/.gitea/workflows/cache-npx.yml @@ -1,17 +1,15 @@ name: Cache Npx on: [push] +env: + DOCKER_REGISTRY: git.zgfxrc.cn + DOCKER_USERNAME: huanghs + jobs: task: runs-on: ubuntu-latest steps: - name: Checkout uses: actions/checkout@v3 - - - run: npm config get cache - - - run: echo ~ - - - run: pwd - name: Get npm cache dir id: npm-cache-dir @@ -26,3 +24,42 @@ jobs: key: ${{ runner.os }}-npx - run: npx cloc . + + - name: Set up QEMU + uses: docker/setup-qemu-action@v2 + + - name: Set up Docker BuildX + uses: docker/setup-buildx-action@v2 + + - name: Login to DockerHub + uses: docker/login-action@v2 + with: + registry: ${{ env.DOCKER_REGISTRY }} + username: ${{ env.DOCKER_USERNAME }} + password: ${{ secrets.GIT_DOCKER_PASSWORD }} + + - name: Cache docker build + uses: actions/cache@v3 + with: + path: /opt/docker-cache/.build-cache + key: ${{ runner.os }}-${{ steps.meta.outputs.REPO_NAME }}-docker-build-cache + + - name: Get Meta + id: meta + run: | + echo REPO_NAME=$(echo ${GITHUB_REPOSITORY} | awk -F"/" '{print $2}') >> $GITHUB_OUTPUT + echo REPO_VERSION=$(echo ${{ github.ref }} | awk -F"/" '{print $3}' | awk -F"v" '{print $2}') >> $GITHUB_OUTPUT + + - name: Build and push + uses: docker/build-push-action@v4 + with: + context: . + file: ./docker/Dockerfile + platforms: | + linux/amd64 + linux/arm64 + push: true + tags: | + ${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_USERNAME }}/action-demo:${{ steps.meta.outputs.REPO_VERSION }} + cache-from: type=local,src=/opt/docker-cache/.build-cache + cache-to: type=local,dest=/opt/docker-cache/.build-cache,mode=max