action-demo/.gitea/workflows/cache-npx.yml

60 lines
1.6 KiB
YAML
Raw Normal View History

2024-07-30 10:35:31 +08:00
name: Cache Npx
on: [push]
2024-08-17 17:22:11 +08:00
env:
DOCKER_REGISTRY: git.zgfxrc.cn
DOCKER_USERNAME: huanghs
2024-07-30 10:35:31 +08:00
jobs:
task:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3
2024-07-30 14:52:55 +08:00
- name: Get npm cache dir
id: npm-cache-dir
run: echo "dir=$(npm config get cache)" >> ${GITHUB_OUTPUT}
- run: echo "${{ steps.npm-cache-dir.outputs.dir }}"
- name: Cache npx
2024-07-30 10:35:31 +08:00
uses: actions/cache@v3
with:
2024-07-30 14:52:55 +08:00
path: ${{ steps.npm-cache-dir.outputs.dir }}/_npx
2024-07-30 10:35:31 +08:00
key: ${{ runner.os }}-npx
2024-07-30 14:39:22 +08:00
- run: npx cloc .
2024-08-17 17:22:11 +08:00
- 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: Build and push
uses: docker/build-push-action@v4
with:
context: .
file: ./docker/Dockerfile
platforms: |
linux/amd64
linux/arm64
push: true
tags: |
2024-08-17 17:25:22 +08:00
${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_USERNAME }}/action-demo:latest
2024-08-17 17:22:11 +08:00
cache-from: type=local,src=/opt/docker-cache/.build-cache
cache-to: type=local,dest=/opt/docker-cache/.build-cache,mode=max