|
| 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 |
0 commit comments