Skip to content

Commit 721a2df

Browse files
Merge branch 'develop' into 8013-history-of-access-request-available-via-api
2 parents c8b949c + dda0fce commit 721a2df

5 files changed

Lines changed: 131 additions & 3 deletions

File tree

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
name: 'Deploy to dataverse-internal.iq.harvard.edu'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
buildlabel:
7+
description: 'Custom label that will appear after the version number (the equivalent of the old "build number" entry). Leaving it empty will default to the legacy behavior, i.e. " build <branch>-<checksum>".'
8+
type: string
9+
required: false
10+
11+
permissions:
12+
contents: read
13+
14+
concurrency:
15+
group: deploy-to-internal
16+
cancel-in-progress: false
17+
18+
jobs:
19+
build:
20+
runs-on: ubuntu-latest
21+
22+
steps:
23+
- uses: actions/checkout@v6
24+
25+
- uses: actions/setup-java@v5
26+
with:
27+
distribution: 'zulu'
28+
java-version: '21'
29+
30+
- name: Set build number
31+
run: scripts/installer/custom-build-number "${{ github.event.inputs.buildlabel }}"
32+
33+
- name: Build application war
34+
run: mvn package
35+
36+
- name: Get war file name
37+
working-directory: target
38+
run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV
39+
40+
- name: Upload war artifact
41+
uses: actions/upload-artifact@v7
42+
with:
43+
name: built-app
44+
path: ./target/${{ env.war_file }}
45+
46+
deploy-to-payara:
47+
needs: build
48+
if: ${{ github.repository_owner == 'IQSS' }}
49+
runs-on: ubuntu-latest
50+
51+
steps:
52+
- uses: actions/checkout@v6
53+
54+
- name: Download war artifact
55+
uses: actions/download-artifact@v8
56+
with:
57+
name: built-app
58+
path: ./
59+
60+
- name: Get war file name
61+
run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV
62+
63+
- name: Copy war file to remote instance
64+
uses: appleboy/scp-action@master
65+
with:
66+
host: ${{ secrets.INTERNAL_PAYARA_INSTANCE_HOST }}
67+
username: ${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }}
68+
key: ${{ secrets.INTERNAL_PAYARA_INSTANCE_SSH_PRIVATE_KEY }}
69+
source: './${{ env.war_file }}'
70+
target: '/home/${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }}'
71+
overwrite: true
72+
73+
- name: Execute payara war deployment remotely
74+
uses: appleboy/ssh-action@v1.2.5
75+
env:
76+
INPUT_WAR_FILE: ${{ env.war_file }}
77+
with:
78+
host: ${{ secrets.INTERNAL_PAYARA_INSTANCE_HOST }}
79+
username: ${{ secrets.INTERNAL_PAYARA_INSTANCE_USERNAME }}
80+
key: ${{ secrets.INTERNAL_PAYARA_INSTANCE_SSH_PRIVATE_KEY }}
81+
envs: INPUT_WAR_FILE
82+
script: |
83+
APPLICATION_NAME=dataverse-backend
84+
ASADMIN='/usr/local/payara7/bin/asadmin --user admin'
85+
$ASADMIN undeploy $APPLICATION_NAME
86+
#$ASADMIN stop-domain
87+
#$ASADMIN start-domain
88+
$ASADMIN deploy --name $APPLICATION_NAME $INPUT_WAR_FILE
89+
#$ASADMIN stop-domain
90+
#$ASADMIN start-domain
Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'Generate dataverse war file'
2+
3+
on:
4+
workflow_dispatch:
5+
inputs:
6+
buildlabel:
7+
description: 'Custom label that will appear after the version number (the equivalent of the old "build number" entry). Leaving it empty will default to the legacy behavior, i.e. " build <branch>-<checksum>".'
8+
type: string
9+
required: false
10+
11+
jobs:
12+
build:
13+
runs-on: ubuntu-latest
14+
15+
steps:
16+
- uses: actions/checkout@v6
17+
18+
- uses: actions/setup-java@v5
19+
with:
20+
distribution: 'zulu'
21+
java-version: '21'
22+
23+
- name: Set build number
24+
run: scripts/installer/custom-build-number "${{ github.event.inputs.buildlabel }}"
25+
26+
- name: Build application war
27+
run: mvn package
28+
29+
- name: Get war file name
30+
working-directory: target
31+
run: echo "war_file=$(ls *.war | head -1)">> $GITHUB_ENV
32+
33+
- name: Upload war artifact
34+
uses: actions/upload-artifact@v7
35+
with:
36+
name: built-app
37+
path: ./target/${{ env.war_file }}

scripts/installer/custom-build-number-hook

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#!/bin/sh
22
# Git changes workdir to root of repo per git documentation
33
BRANCH_COMMIT=$(git rev-parse --abbrev-ref HEAD)-$(git log --oneline | head -1 | awk '{print $1}')
4-
echo "build.number=$BRANCH_COMMIT" > src/main/java/BuildNumber.properties
4+
echo "build.number=build $BRANCH_COMMIT" > src/main/java/BuildNumber.properties
55

66
# Based on https://stackoverflow.com/questions/25590267
77
# $6 = previous branch, $8 is next branch

src/main/java/edu/harvard/iq/dataverse/util/SystemConfig.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -125,7 +125,7 @@ public String getVersion(boolean withBuildNumber) {
125125
}
126126

127127
if (!buildNumber.equals("")) {
128-
return appVersion + " build " + buildNumber;
128+
return appVersion + " " + buildNumber;
129129
}
130130
}
131131

src/test/java/edu/harvard/iq/dataverse/util/SystemConfigTest.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,10 +93,11 @@ void testGetVersionWithBuild() {
9393

9494
// then
9595
assertTrue(result.startsWith("100.100"), "'" + result + "' not starting with 100.100");
96-
assertTrue(result.contains("build"));
9796

9897
// Cannot test this here - there might be the bundle file present which is not under test control
9998
//assertTrue(result.endsWith("FOOBAR"), "'" + result + "' not ending with FOOBAR");
99+
// Not sure what to do about this. The above is correct, if there is a BuildNumber.properties
100+
// file present on the developer's system, it will take precedence. - L.A.
100101
}
101102

102103
@Test

0 commit comments

Comments
 (0)