This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
add cache for maven dependencies #104
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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: | |
flush-compiled-artifacts: | |
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: [flush-compiled-artifacts] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
cache: 'maven' | |
- name: Build | |
run: mvn clean install | |
- name: Cache maven project artifacts | |
uses: actions/cache/save@v3 | |
with: | |
path: target/generated-sources/openapi | |
key: ${{ env.MVN_CACHE_KEY }} | |
- name: Cache npm project artifacts | |
uses: actions/cache/save@v3 | |
with: | |
path: target/generated-sources/npm-package | |
key: ${{ env.NPM_CACHE_KEY }} | |
publish-java-project: | |
needs: [build-project-artifacts] | |
runs-on: ubuntu-latest | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- uses: actions/setup-java@v4 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
cache: 'maven' | |
- name: Retrieve compiled maven project artifacts | |
uses: actions/cache/restore@v3 | |
with: | |
path: target/generated-sources/openapi | |
key: ${{ env.MVN_CACHE_KEY }} | |
fail-on-cache-miss: true | |
- name: Publish package | |
run: | | |
cd target/generated-sources/openapi | |
mvn --batch-mode -DaltDeploymentRepository="$DEPLOYMENT_REPOSITORY" deploy | |
env: | |
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
DEPLOYMENT_REPOSITORY: ${{ secrets.MAVEN_DEPLOYMENT_REPOSITORY_URL}} | |
publish-node-package: | |
needs: [build-project-artifacts] | |
runs-on: ubuntu-latest | |
steps: | |
- name: Retrieve compiled maven project artifacts | |
uses: actions/cache/restore@v3 | |
with: | |
path: target/generated-sources/npm-package | |
key: ${{ env.NPM_CACHE_KEY }} | |
fail-on-cache-miss: true | |
- uses: actions/setup-node@v3 | |
with: | |
node-version: '16.x' | |
registry-url: 'https://npm.pkg.github.com' | |
scope: "@adam-shamaa" | |
- name: Publish NPM Package | |
run: | | |
cd target/generated-sources/npm-package | |
npm publish | |
env: | |
NODE_AUTH_TOKEN: ${{ secrets.GITHUB_TOKEN }} | |
publish-swagger-ui: | |
needs: [publish-java-project, publish-node-package] | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Generate Swagger UI | |
uses: Legion2/swagger-ui-action@v1 | |
with: | |
output: swagger-ui | |
spec-file: ./src/main/resources/openapi/openapi.yaml | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v3 | |
with: | |
github_token: ${{ env.GH_TOKEN }} | |
publish_dir: ./swagger-ui |