Skip to content
This repository has been archived by the owner on Jan 3, 2024. It is now read-only.

Commit

Permalink
flush cache at start of actions workflow
Browse files Browse the repository at this point in the history
  • Loading branch information
adam-shamaa committed Dec 27, 2023
1 parent b917a9b commit 1fc907a
Showing 1 changed file with 35 additions and 6 deletions.
41 changes: 35 additions & 6 deletions .github/workflows/publish-to-github-packages.yml
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -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]
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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

0 comments on commit 1fc907a

Please sign in to comment.