deploy #16
Workflow file for this run
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| name: deploy | |
| on: | |
| workflow_dispatch: | |
| inputs: | |
| environment: | |
| description: Target environment | |
| type: choice | |
| required: true | |
| options: | |
| - beta | |
| - qa | |
| - demo | |
| basepath: | |
| description: 'Server base path (without slashes) for serving the application (e.g., spa). If left blank, it will try to deploy to the root base path.' | |
| type: string | |
| required: false | |
| jobs: | |
| build: | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-node@v3 | |
| with: | |
| node-version: 22 | |
| cache: 'npm' | |
| - name: Create .npmrc | |
| run: | | |
| cp .npmrc.example .npmrc | |
| sed -i -e 's/<YOUR_GITHUB_AUTH_TOKEN>/${{ secrets.GITHUB_TOKEN }}/g' .npmrc | |
| sed -i -e 's/<YOUR_NPM_AUTH_TOKEN>/${{ secrets.NPM_AUTH_TOKEN }}/g' .npmrc | |
| - name: Install Dependencies | |
| run: npm install | |
| - name: Build Dataverse UI Library | |
| working-directory: packages/design-system | |
| run: npm run build | |
| # For BETA environment | |
| - name: Create and populate .env file for BETA | |
| if: ${{ github.event.inputs.environment == 'beta' }} | |
| env: | |
| DATAVERSE_BACKEND_URL: ${{ secrets.BETA_DATAVERSE_BACKEND_URL }} | |
| OIDC_CLIENT_ID: ${{ secrets.BETA_OIDC_CLIENT_ID }} | |
| OIDC_AUTHORIZATION_ENDPOINT: ${{ secrets.BETA_OIDC_AUTHORIZATION_ENDPOINT }} | |
| OIDC_TOKEN_ENDPOINT: ${{ secrets.BETA_OIDC_TOKEN_ENDPOINT }} | |
| OIDC_LOGOUT_ENDPOINT: ${{ secrets.BETA_OIDC_LOGOUT_ENDPOINT }} | |
| OIDC_STORAGE_KEY_PREFIX: ${{ secrets.BETA_OIDC_STORAGE_KEY_PREFIX }} | |
| run: | | |
| touch .env | |
| echo VITE_DATAVERSE_BACKEND_URL="$DATAVERSE_BACKEND_URL" >> .env | |
| echo VITE_OIDC_CLIENT_ID="$OIDC_CLIENT_ID" >> .env | |
| echo VITE_OIDC_AUTHORIZATION_ENDPOINT="$OIDC_AUTHORIZATION_ENDPOINT" >> .env | |
| echo VITE_OIDC_TOKEN_ENDPOINT="$OIDC_TOKEN_ENDPOINT" >> .env | |
| echo VITE_OIDC_LOGOUT_ENDPOINT="$OIDC_LOGOUT_ENDPOINT" >> .env | |
| echo VITE_OIDC_STORAGE_KEY_PREFIX="$OIDC_STORAGE_KEY_PREFIX" >> .env | |
| shell: bash | |
| # For QA environment | |
| - name: Create and populate .env file for QA | |
| if: ${{ github.event.inputs.environment == 'qa' }} | |
| env: | |
| DATAVERSE_BACKEND_URL: ${{ secrets.QA_DATAVERSE_BACKEND_URL }} | |
| OIDC_CLIENT_ID: ${{ secrets.QA_OIDC_CLIENT_ID }} | |
| OIDC_AUTHORIZATION_ENDPOINT: ${{ secrets.QA_OIDC_AUTHORIZATION_ENDPOINT }} | |
| OIDC_TOKEN_ENDPOINT: ${{ secrets.QA_OIDC_TOKEN_ENDPOINT }} | |
| OIDC_LOGOUT_ENDPOINT: ${{ secrets.QA_OIDC_LOGOUT_ENDPOINT }} | |
| OIDC_STORAGE_KEY_PREFIX: ${{ secrets.QA_OIDC_STORAGE_KEY_PREFIX }} | |
| run: | | |
| touch .env | |
| echo VITE_DATAVERSE_BACKEND_URL="$DATAVERSE_BACKEND_URL" >> .env | |
| echo VITE_OIDC_CLIENT_ID="$OIDC_CLIENT_ID" >> .env | |
| echo VITE_OIDC_AUTHORIZATION_ENDPOINT="$OIDC_AUTHORIZATION_ENDPOINT" >> .env | |
| echo VITE_OIDC_TOKEN_ENDPOINT="$OIDC_TOKEN_ENDPOINT" >> .env | |
| echo VITE_OIDC_LOGOUT_ENDPOINT="$OIDC_LOGOUT_ENDPOINT" >> .env | |
| echo VITE_OIDC_STORAGE_KEY_PREFIX="$OIDC_STORAGE_KEY_PREFIX" >> .env | |
| shell: bash | |
| # For DEMO environment | |
| - name: Create and populate .env file for DEMO | |
| if: ${{ github.event.inputs.environment == 'demo' }} | |
| env: | |
| DATAVERSE_BACKEND_URL: ${{ secrets.DEMO_DATAVERSE_BACKEND_URL }} | |
| OIDC_CLIENT_ID: ${{ secrets.DEMO_OIDC_CLIENT_ID }} | |
| OIDC_AUTHORIZATION_ENDPOINT: ${{ secrets.DEMO_OIDC_AUTHORIZATION_ENDPOINT }} | |
| OIDC_TOKEN_ENDPOINT: ${{ secrets.DEMO_OIDC_TOKEN_ENDPOINT }} | |
| OIDC_LOGOUT_ENDPOINT: ${{ secrets.DEMO_OIDC_LOGOUT_ENDPOINT }} | |
| OIDC_STORAGE_KEY_PREFIX: ${{ secrets.DEMO_OIDC_STORAGE_KEY_PREFIX }} | |
| run: | | |
| touch .env | |
| echo VITE_DATAVERSE_BACKEND_URL="$DATAVERSE_BACKEND_URL" >> .env | |
| echo VITE_OIDC_CLIENT_ID="$OIDC_CLIENT_ID" >> .env | |
| echo VITE_OIDC_AUTHORIZATION_ENDPOINT="$OIDC_AUTHORIZATION_ENDPOINT" >> .env | |
| echo VITE_OIDC_TOKEN_ENDPOINT="$OIDC_TOKEN_ENDPOINT" >> .env | |
| echo VITE_OIDC_LOGOUT_ENDPOINT="$OIDC_LOGOUT_ENDPOINT" >> .env | |
| echo VITE_OIDC_STORAGE_KEY_PREFIX="$OIDC_STORAGE_KEY_PREFIX" >> .env | |
| shell: bash | |
| - name: Build with base path | |
| run: npm run build -- --base=/${{ github.event.inputs.basepath }} | |
| - uses: actions/upload-artifact@v4 | |
| with: | |
| name: built-site | |
| path: ./dist | |
| include-hidden-files: true | |
| deploy-to-payara: | |
| needs: build | |
| runs-on: ubuntu-latest | |
| steps: | |
| - uses: actions/checkout@v3 | |
| - uses: actions/setup-java@v3 | |
| with: | |
| distribution: 'zulu' | |
| java-version: '11' | |
| - uses: actions/download-artifact@v4 | |
| with: | |
| name: built-site | |
| path: ./dist | |
| - name: Get branch name | |
| id: branch-name | |
| uses: tj-actions/branch-names@v6 | |
| - name: Build war file | |
| working-directory: ./deployment/payara | |
| run: mvn package "-Dversion=${{ steps.branch-name.outputs.current_branch }}" | |
| # For BETA environment | |
| - name: Copy war file to remote BETA instance | |
| if: ${{ github.event.inputs.environment == 'beta' }} | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.BETA_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.BETA_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.BETA_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| source: './deployment/payara/target/dataverse-frontend.war' | |
| target: '/home/${{ secrets.BETA_PAYARA_INSTANCE_USERNAME }}' | |
| overwrite: true | |
| # For QA environment | |
| - name: Copy war file to remote QA instance | |
| if: ${{ github.event.inputs.environment == 'qa' }} | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.QA_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.QA_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.QA_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| source: './deployment/payara/target/dataverse-frontend.war' | |
| target: '/tmp' | |
| overwrite: true | |
| # For DEMO environment | |
| - name: Copy war file to remote DEMO instance | |
| if: ${{ github.event.inputs.environment == 'demo' }} | |
| uses: appleboy/scp-action@master | |
| with: | |
| host: ${{ secrets.DEMO_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.DEMO_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.DEMO_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| source: './deployment/payara/target/dataverse-frontend.war' | |
| target: '/tmp' | |
| overwrite: true | |
| # For BETA environment | |
| - name: Execute payara war deployment remotely on BETA | |
| if: ${{ github.event.inputs.environment == 'beta' }} | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.BETA_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.BETA_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.BETA_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| script: | | |
| APPLICATION_NAME=dataverse-frontend | |
| APPLICATION_WAR_PATH=deployment/payara/target/$APPLICATION_NAME.war | |
| ASADMIN='/usr/local/payara6/bin/asadmin --user admin' | |
| DATAVERSE_FRONTEND=`$ASADMIN list-applications |grep $APPLICATION_NAME |awk '{print $1}'` | |
| $ASADMIN undeploy $DATAVERSE_FRONTEND | |
| $ASADMIN deploy --name $APPLICATION_NAME --contextroot /${{ github.event.inputs.basepath }} $APPLICATION_WAR_PATH | |
| # For QA environment | |
| - name: Execute payara war deployment remotely on QA | |
| if: ${{ github.event.inputs.environment == 'qa' }} | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.QA_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.QA_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.QA_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| script: | | |
| APPLICATION_NAME=dataverse-frontend | |
| APPLICATION_WAR_PATH=/tmp/deployment/payara/target/$APPLICATION_NAME.war | |
| ASADMIN='/usr/local/payara6/bin/asadmin --user admin' | |
| DATAVERSE_FRONTEND=`$ASADMIN list-applications |grep $APPLICATION_NAME |awk '{print $1}'` | |
| $ASADMIN undeploy $DATAVERSE_FRONTEND | |
| $ASADMIN deploy --name $APPLICATION_NAME --contextroot /${{ github.event.inputs.basepath }} $APPLICATION_WAR_PATH | |
| # For DEMO environment | |
| - name: Execute payara war deployment remotely on DEMO | |
| if: ${{ github.event.inputs.environment == 'demo' }} | |
| uses: appleboy/[email protected] | |
| with: | |
| host: ${{ secrets.DEMO_PAYARA_INSTANCE_HOST }} | |
| username: ${{ secrets.DEMO_PAYARA_INSTANCE_USERNAME }} | |
| key: ${{ secrets.DEMO_PAYARA_INSTANCE_SSH_PRIVATE_KEY }} | |
| script: | | |
| APPLICATION_NAME=dataverse-frontend | |
| APPLICATION_WAR_PATH=/tmp/deployment/payara/target/$APPLICATION_NAME.war | |
| ASADMIN='/usr/local/payara6/bin/asadmin --user admin' | |
| DATAVERSE_FRONTEND=`$ASADMIN list-applications |grep $APPLICATION_NAME |awk '{print $1}'` | |
| $ASADMIN undeploy $DATAVERSE_FRONTEND | |
| $ASADMIN deploy --name $APPLICATION_NAME --contextroot /${{ github.event.inputs.basepath }} $APPLICATION_WAR_PATH |