From e48d5df2027c69a4c05ed72b473d9a2b895ab4e3 Mon Sep 17 00:00:00 2001 From: Ali Mihandoost Date: Mon, 27 Nov 2023 15:58:32 +0330 Subject: [PATCH] chore(ci): review and enhance --- .github/workflows/build-lint.yaml | 9 ++++++--- .github/workflows/publish-container.yml | 23 ++++++++++++++--------- .github/workflows/publish-npm.yml | 3 ++- 3 files changed, 22 insertions(+), 13 deletions(-) diff --git a/.github/workflows/build-lint.yaml b/.github/workflows/build-lint.yaml index 30676e84..69c1d0b1 100644 --- a/.github/workflows/build-lint.yaml +++ b/.github/workflows/build-lint.yaml @@ -39,13 +39,16 @@ jobs: id: yarn_config run: echo "cache_folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3.3.2 + - name: 🏗 Cache Layer + uses: actions/cache@v3.3.2 # id: yarn_cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: - path: ${{ steps.yarn_config.outputs.cache_folder }} + path: | + ${{ steps.yarn_config.outputs.cache_folder }} + /tmp/.buildx-cache key: ${{ runner.os }}-yarn-${{ hashFiles('yarn.lock') }} restore-keys: | - ${{ runner.os }}-yarn- + ${{ runner.os }}-yarn - name: 🏗 Install dependencies run: yarn install --immutable diff --git a/.github/workflows/publish-container.yml b/.github/workflows/publish-container.yml index 9ac8ea13..76d78e39 100644 --- a/.github/workflows/publish-container.yml +++ b/.github/workflows/publish-container.yml @@ -29,8 +29,12 @@ jobs: fail-fast: false matrix: include: - - path: api - - path: nginx + - name: storage-api + path: ./packages/api + context: . + - name: storage-nginx + path: ./packages/nginx + context: ./packages/nginx permissions: contents: read @@ -48,7 +52,7 @@ jobs: with: filters: | container_folder: - ./packages/${{ matrix.path }}/* + ${{ matrix.context }}/** - name: 🏗 Install cosign if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }} @@ -60,10 +64,10 @@ jobs: - name: 🏗 Cache Docker Layers if: ${{ steps.file_change.outputs.container_folder != 'false' }} - uses: actions/cache@v3 + uses: actions/cache@v3.3.2 with: path: /tmp/.buildx-cache - key: container/${{ matrix.path }} + key: container/${{ matrix.name }} - name: 🏗 Log into docker hub registry if: ${{ github.event_name != 'pull_request' && steps.file_change.outputs.container_folder != 'false' }} @@ -87,15 +91,15 @@ jobs: with: github-token: ${{secrets.GITHUB_TOKEN}} images: | - name=ghcr.io/${{env.USER}}/storage-${{matrix.path}},enable=true - name=docker.io/${{env.USER}}/storage-${{matrix.path}},enable=true + name=ghcr.io/${{env.USER}}/${{matrix.name}},enable=true + name=docker.io/${{env.USER}}/${{matrix.name}},enable=true tags: | type=semver,enable=true,pattern={{major}} type=semver,enable=true,pattern={{major}}.{{minor}} type=semver,enable=true,pattern={{version}} type=ref,enable=true,event=branch labels: | - org.opencontainers.image.title="alwatr/storage-${{matrix.path}}" + org.opencontainers.image.title="alwatr/${{matrix.name}}" org.opencontainers.image.vendor="Alwatr" org.opencontainers.image.documentation="https://github.com/Alwatr/storage" org.opencontainers.image.authors="S. Ali Mihandoost (https://ali.mihandoost.com)" @@ -105,7 +109,8 @@ jobs: id: build_and_push uses: docker/build-push-action@v5.1.0 with: - context: ./packages/${{matrix.path}} + context: ${{matrix.context}} + file: ${{matrix.path}}/Dockerfile push: ${{ github.event_name != 'pull_request' }} tags: ${{ steps.meta.outputs.tags }} labels: ${{ steps.meta.outputs.labels }} diff --git a/.github/workflows/publish-npm.yml b/.github/workflows/publish-npm.yml index 68f61ba7..5c6e3b23 100644 --- a/.github/workflows/publish-npm.yml +++ b/.github/workflows/publish-npm.yml @@ -39,7 +39,8 @@ jobs: id: yarn_config run: echo "cache_folder=$(yarn config get cacheFolder)" >> $GITHUB_OUTPUT - - uses: actions/cache@v3.3.2 + - name: 🏗 Cache Layer + uses: actions/cache@v3.3.2 # id: yarn_cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`) with: path: ${{ steps.yarn_config.outputs.cache_folder }}