Deploy to prod #45
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: Deploy to prod | |
on: | |
workflow_dispatch: | |
jobs: | |
prcheck: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Create folder for frontend | |
run: 'sudo mkdir /su_frontend' | |
- name: Use custom node version | |
uses: actions/setup-node@v3 | |
with: | |
node-version: 20 | |
- name: Node version | |
run: "node --version" | |
- name: Checkout frontend repo TeachUAClient | |
uses: actions/checkout@v3 | |
with: | |
repository: ita-social-projects/TeachUAClient | |
ref: develop | |
- name: Install dependencies | |
run: "npm install --legacy-peer-deps" | |
continue-on-error: true | |
- name: Build frontend | |
run: "CI=false npm run build" | |
- name: copy frontend to frontend folder | |
run: 'sudo cp -r build/* /su_frontend' | |
- name: Checkout backend repo TeachUA | |
uses: actions/checkout@v3 | |
with: | |
repository: ita-social-projects/TeachUA | |
ref: rest | |
- name: Change properties to prod | |
run: "sudo sed -i 's/spring.profiles.active=.*/spring.profiles.active=prod/' src/main/resources/application.properties" | |
- name: Inject frontend | |
run: 'sudo cp -r /su_frontend/* src/main/resources/frontend' | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
cache: maven | |
- name: Java version | |
run: "java -version" | |
- name: Build war | |
run: 'mvn package -DskipTests -Dcheckstyle.skip' | |
##run: 'mvn package' | |
- name: Copy results to the remote host over SSH | |
uses: appleboy/scp-action@master | |
with: | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
port: ${{ secrets.PORT }} | |
source: "target/dev.war" | |
target: "/root/deploy" | |
strip_components: 1 | |
- name: Move to tomcat server | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: mv /root/deploy/dev.war /opt/tomcat/latest/webapps/ROOT.war | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
privateKey: ${{ secrets.SSH_PRIVATE_KEY}} | |
- name: Change permissions to tomcat user | |
uses: garygrossgarten/github-action-ssh@release | |
with: | |
command: chown -R tomcat:tomcat /opt/tomcat | |
host: ${{ secrets.HOST }} | |
username: ${{ secrets.USER }} | |
privateKey: ${{ secrets.SSH_PRIVATE_KEY}} |