From 1fc907a332b7fd2fc6f93cb869580ccd1cf16bc2 Mon Sep 17 00:00:00 2001 From: Adam Shamaa Date: Wed, 27 Dec 2023 04:14:38 -0500 Subject: [PATCH] flush cache at start of actions workflow --- .../workflows/publish-to-github-packages.yml | 41 ++++++++++++++++--- 1 file changed, 35 insertions(+), 6 deletions(-) diff --git a/.github/workflows/publish-to-github-packages.yml b/.github/workflows/publish-to-github-packages.yml index 851dc5c..91e81e4 100644 --- a/.github/workflows/publish-to-github-packages.yml +++ b/.github/workflows/publish-to-github-packages.yml @@ -1,7 +1,34 @@ name: Publish package to GitHub Packages on: [push] +env: + NPM_CACHE_KEY: "COMPILED_NPM_PROJECT" + MVN_CACHE_KEY: "COMPILED_MAVEN_PROJECT" + GH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + jobs: + clear-cache: + runs-on: ubuntu-latest + permissions: + contents: read + actions: write + steps: + - name: Checkout + uses: actions/checkout@v3 + + - name: Delete Cached Maven Project Artifacts + continue-on-error: true + run: | + gh extension install actions/gh-actions-cache + gh actions-cache delete "${{ env.NPM_CACHE_KEY }}" --confirm + + - name: Delete Cached NPM Project Artifacts + continue-on-error: true + run: | + gh extension install actions/gh-actions-cache + gh actions-cache delete "${{ env.MVN_CACHE_KEY }}" --confirm + build-project-artifacts: + needs: [clear-cache] runs-on: ubuntu-latest steps: - uses: actions/checkout@v3 @@ -18,13 +45,13 @@ jobs: uses: actions/cache/save@v3 with: path: target/generated-sources/openapi - key: compiled-maven-project + key: ${{ env.MVN_CACHE_KEY }} - name: Cache npm project artifacts uses: actions/cache/save@v3 with: path: target/generated-sources/npm-package - key: compiled-npm-project + key: ${{ env.NPM_CACHE_KEY }} publish-java-project: needs: [build-project-artifacts] @@ -37,12 +64,12 @@ jobs: with: java-version: '11' distribution: 'adopt' - + - name: Retrieve compiled maven project artifacts uses: actions/cache/restore@v3 with: path: target/generated-sources/openapi - key: compiled-maven-project + key: ${{ env.MVN_CACHE_KEY }} fail-on-cache-miss: true - name: Publish package @@ -52,6 +79,7 @@ jobs: env: GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} DEPLOYMENT_REPOSITORY: ${{ secrets.MAVEN_DEPLOYMENT_REPOSITORY_URL}} + publish-node-package: needs: [build-project-artifacts] runs-on: ubuntu-latest @@ -60,7 +88,7 @@ jobs: uses: actions/cache/restore@v3 with: path: target/generated-sources/npm-package - key: compiled-npm-project + key: ${{ env.NPM_CACHE_KEY }} fail-on-cache-miss: true - uses: actions/setup-node@v3 @@ -75,6 +103,7 @@ jobs: npm publish env: NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} + publish-swagger-ui: needs: [publish-java-project, publish-node-package] runs-on: ubuntu-latest @@ -90,5 +119,5 @@ jobs: - name: Deploy to GitHub Pages uses: peaceiris/actions-gh-pages@v3 with: - github_token: ${{ secrets.GITHUB_TOKEN }} + github_token: ${{ env.GH_TOKEN }} publish_dir: ./swagger-ui