Merge pull request #36 from soasada/dependabot/npm_and_yarn/frontend/… #53
This file contains 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: Undertow & Vue.js CI | |
on: [push] | |
jobs: | |
ci_cd_job: | |
name: Undertow & Vue.js pipeline | |
runs-on: ubuntu-latest | |
env: | |
KILL_JAVA_SH: ${{ github.workspace }}/ci/kill_java_process.sh | |
SERVER_PUB_KEY: ${{ github.workspace }}/data/server/server_pub_key.txt | |
JAR_TO_DEPLOY: ${{ github.workspace }}/backend/target/backend-0.0.1.jar | |
steps: | |
- name: Check out repository | |
uses: actions/checkout@v2 | |
- name: Run docker-compose | |
run: docker-compose up -d | |
- name: Set up JDK 14 | |
uses: actions/setup-java@v1 | |
with: | |
java-version: 14 | |
- name: Testing migrations | |
run: mvn -B clean -pl :backend -Dflyway.configFiles=src/main/resources/database/test_migrations.properties flyway:migrate | |
- name: Test & Package frontend | |
run: mvn -B clean install -pl :frontend | |
- name: Test & Package backend | |
run: export APP_ENV=test && mvn -B clean test package -pl :backend | |
- name: Prepare SSH Keys | |
run: | | |
mkdir -p ~/.ssh | |
echo "${{ secrets.KEY }}" > ~/.ssh/id_rsa | |
chmod 600 ~/.ssh/id_rsa | |
cat "$SERVER_PUB_KEY" > ~/.ssh/known_hosts | |
chmod 600 ~/.ssh/known_hosts | |
- name: Launching migrations into production | |
run: | | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "mysql -uroot -proot <<< 'DROP DATABASE IF EXISTS production_db; CREATE DATABASE production_db;'" | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "git clone https://github.com/soasada/undertow-vuejs.git" | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "export JAVA_HOME=~/jdk && ~/maven/bin/mvn -f undertow-vuejs/backend/pom.xml flyway:migrate" | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "rm -rf undertow-vuejs" | |
- name: Kill java process | |
run: | | |
ssh -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} 'bash -s' < $KILL_JAVA_SH | |
- name: Copy jar to server | |
run: | | |
scp -P ${{ secrets.PORT }} $JAR_TO_DEPLOY ${{ secrets.USERNAME }}@${{ secrets.HOST }}:~/undertow-vuejs-0.0.1.jar | |
- name: Launch app | |
run: | | |
ssh -f -p ${{ secrets.PORT }} ${{ secrets.USERNAME }}@${{ secrets.HOST }} "export APP_ENV=prod && ~/jdk/bin/java -Xms64M -Xmx256M -Dlogfilename=web -Dlog4j2.contextSelector=org.apache.logging.log4j.core.async.AsyncLoggerContextSelector -jar undertow-vuejs-0.0.1.jar &" |