This repository has been archived by the owner on Jan 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
132 lines (113 loc) · 3.84 KB
/
publish-to-github-packages.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
name: Publish package to GitHub Packages
on:
push:
branches:
- main
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/checkout@v4
- 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: |
mkdir -p ~/.m2
echo "<settings><servers><server><id>gh</id><username>$(echo "$GITHUB_REPOSITORY" | awk -F / '{print $1}')</username><password>\${env.GH_TOKEN}</password></server></servers></settings>" > ~/.m2/settings.xml
cd target/generated-sources/openapi
mvn --batch-mode deploy -DaltDeploymentRepository="${{env.MVN_GH_REPO}}" -DaltSnapshotDeploymentRepository="${{env.MVN_GH_REPO}}"
env:
MVN_GH_REPO: "gh::default::https://maven.pkg.github.com/${GITHUB_REPOSITORY}"
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: ${{ env.GH_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