-
Notifications
You must be signed in to change notification settings - Fork 1
131 lines (113 loc) · 4.1 KB
/
bygg_alle_brancher.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
name: "Build npm and deploy Maven-artifact. See the step 'Deploy Maven artifact...' for Maven dependency/version"
permissions:
deployments: write
packages: write
contents: write
on:
push:
branches:
- '*'
- '*/*'
jobs:
tag_build_and_deploy:
name: 'Build'
runs-on: ubuntu-latest
env:
application: "eux-web-app"
strategy:
matrix:
node-version: [16.x]
steps:
# PULL REPOSITORY
- name: 'Pull repository'
uses: actions/checkout@v1
# CACHE NODE
- name: Cache node modules
uses: actions/cache@v1
env:
cache-name: cache-node-modules
with:
path: ./node_modules
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('package.json') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# CACHE MAVEN
- name: Cache maven plugin dependencies
uses: actions/cache@v1
env:
cache-name: cache-mvn-plugin
with:
path: ~/.m2/repository
key: ${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}-${{ hashFiles('settings.xml') }}
restore-keys: |
${{ runner.os }}-build-${{ env.cache-name }}-${{ matrix.node-version }}
${{ runner.os }}-build-${{ env.cache-name }}-
${{ runner.os }}-build-
${{ runner.os }}-
# SETUP NODE
- name: 'Setup Node'
uses: actions/setup-node@v2.1.2
with:
node-version: 16.x
registry-url: https://npm.pkg.github.com/
scope: "@navikt"
# INSTALL NPM DEPENDENCIES
- name: 'Install NPM dependencies'
run: |
application="eux-web-app"
npm install --force
env:
NODE_AUTH_TOKEN: ${{ secrets.READER_TOKEN }}
# BUILD NPM
- name: 'Build npm'
run: |
RAW_SEMVER=`node -pe "require('./package.json').version"`
SEMVER=`echo -e "${RAW_SEMVER}" | tr -d '[:space:]'`
echo "semver=${SEMVER}"
echo "SEMVER=$SEMVER" >> $GITHUB_ENV
echo "npm run build"
npm run build
# ZIP FRONTEND
- name: 'Zip the frontend'
run: |
echo "copying content"
frontendDir="${GITHUB_WORKSPACE}/eux-web-app"
echo $frontendDir
mkdir -p $frontendDir
rm -rf $frontendDir/*
cp -r build/* $frontendDir
buildVersion="${SEMVER}-${GITHUB_RUN_ID}"
echo "buildVersion=${buildVersion}"
zipFile="${application}-${buildVersion}.zip"
cd build
zip -r ${zipFile} *
cd ..
mv build/${zipFile} ./${zipFile}
major=${SEMVER%%.*}
minor=${SEMVER/major./}
minor=${minor%%.*}
qualifier="${GITHUB_RUN_ID}"
version="${major}.${minor}-${qualifier}"
versionZipfile="${application}-${version}.zip"
echo "versionZipfile=${versionZipfile}"
mv ${zipFile} ${versionZipfile}
echo "version=$version" >> $GITHUB_ENV
echo "versionZipfile=$versionZipfile" >> $GITHUB_ENV
# DEPLOY MAVEN ARTIFACT
- name: "Deploy Maven artifact to NAV IKT's GitHub Package Registry"
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
echo "<dependency>"
echo " <groupId>no.nav.eux</groupId>"
echo " <artifactId>${application}</artifactId>"
echo " <version>${version}</version>"
echo "</dependency>"
mvn --settings settings.xml deploy:deploy-file -Dfile=${versionZipfile} -DartifactId=${application} -DgroupId=no.nav.eux -Dversion=${version} -Ddescription='Eux-web-app JavaScript resources.' -Durl=https://maven.pkg.github.com/navikt/eux-web-app -DrepositoryId=github
- name: 'Echo Version'
run: |
echo "## Version:" >> $GITHUB_STEP_SUMMARY
echo "${version}" >> $GITHUB_STEP_SUMMARY