Skip to content

Deploy

Deploy #3

Workflow file for this run

name: Deploy
on:
workflow_run:
workflows: [ CI ]
types: [ completed ]
branches: [ main ]
jobs:
build:
runs-on: ubuntu-latest
if: ${{ github.event.workflow_run.conclusion == 'success' }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
cache: 'maven'
server-id: github-l3s-learnweb
- run: mvn --quiet -P prod,!local -Dmaven.test.skip=true install
env:
GITHUB_TOKEN: ${{ secrets.GH_PAT }}
- uses: actions/upload-artifact@v3
with:
name: learnweb-war
path: target/Learnweb.war
if-no-files-found: error
- uses: actions/upload-artifact@v3
with:
name: learnweb-war
path: target/classes/release.properties
if-no-files-found: error
deploy-dev:
runs-on: ubuntu-latest
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: learnweb-war
- run: ls -l -R
- name: Read version
id: vars
run: echo "version=$(cat release.properties | grep project.version | cut -d'=' -f2)" >> $GITHUB_OUTPUT
- name: Test output
run: echo ${{ steps.vars.outputs.version }}
- name: rename artifact
run: mv Learnweb.war dev##${{ steps.vars.outputs.version }}.war
- name: deploy war to staging
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
proxy_host: ${{ secrets.DEPLOY_JUMP_HOST }}
proxy_username: ${{ secrets.DEPLOY_JUMP_USERNAME }}
proxy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
source: "dev##*.war"
target: ${{ secrets.DEPLOY_PATH }}
deploy-prod:
runs-on: ubuntu-latest
if: startsWith(github.event.head_commit.message, 'chore') && endsWith(github.event.head_commit.message, 'version release')
needs: [ build ]
steps:
- uses: actions/download-artifact@v3
with:
name: learnweb-war
- name: read version
id: vars
run: echo "version=$(cat release.properties | grep project.version | cut -d'=' -f2)" >> $GITHUB_OUTPUT
- name: rename artifact
run: mv Learnweb.war ROOT##${{ steps.vars.outputs.version }}.war
- name: deploy war to staging
uses: appleboy/[email protected]
with:
host: ${{ secrets.DEPLOY_HOST }}
username: ${{ secrets.DEPLOY_USERNAME }}
key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
proxy_host: ${{ secrets.DEPLOY_JUMP_HOST }}
proxy_username: ${{ secrets.DEPLOY_JUMP_USERNAME }}
proxy_key: ${{ secrets.DEPLOY_PRIVATE_KEY }}
source: "ROOT##*.war"
target: ${{ secrets.DEPLOY_PATH }}
tar_exec: "tar --keep-old-files"