-
Notifications
You must be signed in to change notification settings - Fork 0
210 lines (191 loc) · 7.13 KB
/
node-release.yaml
File metadata and controls
210 lines (191 loc) · 7.13 KB
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
name: "Release"
on:
workflow_call:
inputs:
build_script:
description: "Build script to be executed"
type: string
default: 'npm run build'
workspace:
description: "The default working directory on the runner for steps, and the default location of your repository when using the checkout action"
type: string
default: ${{ github.workspace }}
npm-publish:
description: "Determines if packages will be published to npm registry"
type: string
default: 'true'
node-version:
description: "NodeJS version"
type: string
default: ""
github-registries:
description: "Namespaces of github registries (comma separated)"
type: string
required: false
cache-key:
description: "Cache key to be restored"
type: string
required: false
cache-path:
description: "Path which cache will be restored"
type: string
required: false
dockerize:
description: "Determines if docker image will be created"
type: string
default: 'true'
docker-cwd:
description: "Working directory for docker build"
type: string
docker-platforms:
description: "Comma seperated target platforms for Docker images"
type: string
default: 'linux/amd64'
stage-repository:
description: "Git repository for stage files"
type: string
stage-repository-branch:
description: "Git repository for stage files"
type: string
default: 'main'
stage-files:
description: "<cr> delimited pairing of <Package name=Stage files>"
type: string
image-files:
description: "<cr> delimited pairing of <Package name=Image file name>"
type: string
ignore-packages:
description: "Comma separated list of packages to be ignored"
type: string
secrets:
PERSONAL_ACCESS_TOKEN:
description: "Github personal access token"
required: true
NPM_TOKEN:
description: "Access token for npm.pkg.github.com repository"
required: false
DOCKERHUB_NAMESPACE:
description: "Dockerhub namespace. Required if 'stage-repository' defined"
required: false
DOCKERHUB_USERNAME:
description: "Dockerhub username. Required if 'dockerize' is set true"
required: false
DOCKERHUB_PASS:
description: "Dockerhub password. Required if 'dockerize' is set true"
required: false
jobs:
release:
name: "Release"
runs-on: ubuntu-latest
outputs:
packages: ${{ steps.environment.outputs.packages }}
steps:
- name: "Setup Environment"
uses: panates/gh-setup-node@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fetch-depth: 100
node-version: ${{ inputs.node-version }}
github-registries: ${{ inputs.github-registries }}
- name: "Restore Cache"
if: ${{ inputs.cache-key != '' && inputs.cache-path != '' }}
uses: actions/cache/restore@v5
with:
path: ${{ inputs.cache-path }}
key: ${{ inputs.cache-key }}
- name: "Print Info"
run: |
echo "=== NODE / NPM ==="
node -v
npm -v
echo "=== WORKFLOW ==="
echo "GITHUB_WORKFLOW=$GITHUB_WORKFLOW"
echo "GITHUB_WORKFLOW_REF=$GITHUB_WORKFLOW_REF"
echo "GITHUB_REPOSITORY=$GITHUB_REPOSITORY"
echo "=== NPM FULL CONFIG ==="
npm config list
echo "=== RESTORED CACHE ==="
ls -R "${{ inputs.cache-path }}" 2>/dev/null || echo "Cache path not found"
- name: "Scan Environment"
id: environment
uses: panates/gh-repository-info@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
- name: "Check git tag"
run: |
if [ -z "${{ steps.environment.outputs.lastTag }}" ]; then
echo "Error: No git tag found."
exit 1
fi
- name: "Build Changelog"
id: changelog
uses: panates/github-actions/.github/actions/node-build-changelog@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
fromTag: ${{ steps.environment.outputs.prevSha }}
toTag: ${{ steps.environment.outputs.lastSha }}
- name: "Print changelog"
run: |
cat COMMIT_CHANGELOG.md
- name: "Build Packages"
shell: bash
run: |
${{ inputs.build_script }}
- name: "Publish Npm Packages"
if: ${{ steps.environment.outputs.npmPackages && inputs.npm-publish == 'true'}}
uses: panates/github-actions/.github/actions/release-npm@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
npm-token: ${{ secrets.NPM_TOKEN }}
workspace: ${{ inputs.workspace }}
packages: ${{ steps.environment.outputs.packages }}
github-registries: ${{ inputs.github-registries }}
ignore-packages: ${{ inputs.ignore-packages }}
- name: "Build Docker Images"
if: ${{ steps.environment.outputs.dockerPackages && inputs.dockerize == 'true'}}
uses: panates/github-actions/.github/actions/release-docker@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
workspace: ${{ inputs.workspace }}
packages: ${{ steps.environment.outputs.packages }}
platforms: ${{ inputs.docker-platforms }}
dockerhub-namespace: ${{ secrets.DOCKERHUB_NAMESPACE }}
docherhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
docherhub-password: ${{ secrets.DOCKERHUB_PASS }}
image-files: ${{ inputs.image-files }}
cwd: ${{ inputs.docker-cwd }}
cache-path: ${{ inputs.cache-path }}
ignore-packages: ${{ inputs.ignore-packages }}
- name: "Create GitHub Release"
id: create_release
uses: ncipollo/release-action@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
tag: ${{ steps.environment.outputs.lastTag }}
bodyFile: "COMMIT_CHANGELOG.md"
allowUpdates: true
draft: false
prerelease: false
replacesArtifacts: true
stage_deploy:
if: ${{ inputs.stage-repository != '' }}
name: Stage Deploy
needs: release
runs-on: ubuntu-latest
steps:
- name: Checkout manifest repository
uses: actions/checkout@v6
with:
repository: ${{ inputs.stage-repository }}
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
ref: ${{ inputs.stage-repository-branch }}
- name: Update image in deployment yaml
uses: panates/github-actions/.github/actions/stage-deploy@v1
with:
token: ${{ secrets.PERSONAL_ACCESS_TOKEN }}
packages: ${{ needs.release.outputs.packages }}
dockerhub-namespace: ${{ secrets.DOCKERHUB_NAMESPACE }}
docherhub-username: ${{ secrets.DOCKERHUB_USERNAME }}
docherhub-password: ${{ secrets.DOCKERHUB_PASS }}
image-files: ${{ inputs.image-files }}
stage-files: ${{ inputs.stage-files }}