-
Notifications
You must be signed in to change notification settings - Fork 0
147 lines (131 loc) · 4.65 KB
/
cut-tag-javascript.yml
File metadata and controls
147 lines (131 loc) · 4.65 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
on:
workflow_call:
secrets:
ARTIFACTORY_TOKEN:
required: true
ARTIFACTORY_USERNAME:
required: true
ARTIFACTORY_IDENTITY_TOKEN:
required: true
UPDATE_MANIFEST_TOKEN:
required: true
CONTENTFUL_ACCESS_TOKEN:
required: false
CONTENTFUL_PREVIEW_ACCESS_TOKEN:
required: false
CONTENTFUL_SPACE_ID:
required: false
CONTENTFUL_ENVIRONMENT_ID:
required: false
inputs:
NX_APP:
type: string
required: true
ARTIFACTORY_REGISTRY:
required: true
type: string
outputs:
tag_name:
description: "Git Tag Name"
value: ${{ jobs.tag_version.outputs.tag_name }}
permissions:
contents: write
env:
NX_APP: ${{ inputs.NX_APP }}
ARTIFACTORY_USERNAME: ${{ secrets.ARTIFACTORY_USERNAME }}
ARTIFACTORY_IDENTITY_TOKEN: ${{ secrets.ARTIFACTORY_IDENTITY_TOKEN }}
UPDATE_MANIFEST_TOKEN: ${{ secrets.UPDATE_MANIFEST_TOKEN }}
ARTIFACTORY_TOKEN: ${{ secrets.ARTIFACTORY_TOKEN }}
ARTIFACTORY_REGISTRY: ${{ inputs.ARTIFACTORY_REGISTRY }}
CONTENTFUL_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_ACCESS_TOKEN || '' }}
CONTENTFUL_PREVIEW_ACCESS_TOKEN: ${{ secrets.CONTENTFUL_PREVIEW_ACCESS_TOKEN || '' }}
CONTENTFUL_SPACE_ID: ${{ secrets.CONTENTFUL_SPACE_ID || '' }}
CONTENTFUL_ENVIRONMENT_ID: ${{ secrets.CONTENTFUL_ENVIRONMENT_ID || '' }}
INPUT_GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
NODE_OPTIONS: "--max_old_space_size=4096"
jobs:
tag_version:
name: Create Tag & Build
runs-on: ubuntu-latest
outputs:
tag_name: ${{ steps.TAG.outputs.code_version }}
steps:
- name: Checkout Code
uses: actions/checkout@v3
with:
fetch-depth: 0
- name: Login to Artifactory Container Registry
uses: docker/login-action@v2
with:
registry: naxgrp.jfrog.io
username: ${{ secrets.ARTIFACTORY_USERNAME }}
password: ${{ secrets.ARTIFACTORY_IDENTITY_TOKEN }}
- name: Setup NodeJS 18
uses: actions/setup-node@v1
with:
node-version: 18
- name: Install pnpm
run: npm install -g pnpm
- name: Get pnpm cache directory path
id: pnpm-cache-dir-path
run: echo "::set-output name=dir::$(pnpm config get cacheFolder)"
- name: Cache pnpm dependencies
uses: actions/cache@v2
id: pnpm-cache
with:
path: |
${{ steps.pnpm-cache-dir-path.outputs.dir }}
**\node_modules
key: ${{ runner.os }}-pnpm-${{ hashFiles('**/pnpm-lock.yaml') }}
restore-keys: |
${{ runner.os }}-pnpm-
- name: Install dependencies
if: steps.pnpm-cache.outputs.cache-hit != 'true'
run: pnpm install
- name: Get Tag Version
id: TAG
run: |
cd apps/$NX_APP && app_version=$(npm version minor --no-git-tag-version --no-push) && cd ../..
npm version minor --no-git-tag-version --no-push
echo "${{ inputs.NX_APP }}: $app_version"
echo "Code version: ${{ inputs.NX_APP }}_$app_version"
echo "app_version=$app_version" >> $GITHUB_OUTPUT
echo "code_version=${{ inputs.NX_APP }}_$app_version" >> $GITHUB_OUTPUT
- name: Push changes
run: |
git fetch
git config user.email "github@naxgrp.com"
git config user.name "Github CI"
git add --all
git commit -m "Release version ${{ steps.TAG.outputs.code_version }}"
git push
- name: Tag release
run: |
git tag -a ${{ steps.TAG.outputs.code_version }} -m "tag release ${{ steps.TAG.outputs.code_version }}"
git push --follow-tags
- name: Build apps
run: |
pnpm nx build $NX_APP
- name: Set up Docker Buildx
id: buildx
uses: docker/setup-buildx-action@v2
- name: Build and push docker image
id: build_image
env:
INPUT_PLATFORMS: linux/amd64,linux/arm64
run: |
pnpm nx deploy $NX_APP
echo "$(cat .nx-container/$NX_APP/digest)" >> digest.txt
echo $NX_APP >> app.txt
echo "digest=$(cat .nx-container/$NX_APP/digest)" >> $GITHUB_OUTPUT
- uses: ncipollo/release-action@v1.12.0
with:
name: "${{ steps.TAG.outputs.code_version }}"
tag: ${{ steps.TAG.outputs.code_version }}
makeLatest: true
artifacts: "digest.txt,app.txt"
removeArtifacts: true
generateReleaseNotes: true
body: |
App: `${{ inputs.NX_APP }}`
Docker Digest: `${{ steps.build_image.outputs.digest }}`