Merge pull request #233 from ogomaemmanuel/node-sass #310
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: Main Branch | |
on: | |
push: | |
branches: [ master] | |
# branches: [ release ] | |
# pull_request: | |
# branches: [ master] | |
# branches: [ release] | |
jobs: | |
test: | |
name: Unit Test | |
defaults: | |
run: | |
working-directory: hr_core | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- uses: actions/setup-node@v3 | |
name: build client packages | |
with: | |
node-version: 18 | |
- run: | | |
git config --global url."https://github.com".insteadOf git://github.com | |
npm install | |
- run: npm run prod | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
cache: 'maven' | |
- name: Maven Verify | |
run: mvn -B clean verify | |
- name: Maven Package | |
run: mvn -B clean package -DskipTests | |
- name: Archive jar files to be used in deploy step | |
uses: actions/upload-artifact@v3 | |
with: | |
name: hr-jars | |
path: hr_core/target/*.jar | |
docker: | |
needs: test | |
defaults: | |
run: | |
working-directory: hr_core | |
name: Publish - Docker Hub | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v2 | |
- name: Login to DockerHub | |
uses: docker/login-action@v2 | |
with: | |
username: ${{ secrets.DOCKER_USER }} | |
password: ${{ secrets.DOCKER_PASS }} | |
- name: Build and push | |
uses: docker/build-push-action@v3 | |
with: | |
platforms: linux/amd64,linux/arm64 | |
context: "{{defaultContext}}:hr_core" | |
push: true | |
tags: mudho/hr:latest | |
deploy: | |
needs: test | |
runs-on: ubuntu-latest | |
name: Deploy to oracle compute vm | |
steps: | |
- name: Checkout | |
uses: actions/checkout@v3 | |
- name: Download JAR | |
uses: actions/download-artifact@v3 | |
with: | |
name: 'hr-jars' | |
path: ~/hr-jars | |
- name: create deploy key | |
run: | | |
echo "${{secrets.ORACLE_COMPUTE_817_DEPLOY_KEY}}" > deploy_key | |
chmod 600 ./deploy_key | |
- name: Create jar folder on remote machine | |
run: | | |
ssh -i ./deploy_key -o 'StrictHostKeyChecking=no' opc@${{ secrets.ORACLE_COMPUTE_HOST_817 }} 'mkdir -p hr-jars' | |
- name: Rsynch files | |
run: | | |
rsync -e 'ssh -i ./deploy_key -o StrictHostKeyChecking=no' -avzr --progress ~/hr-jars/*.jar opc@${{ secrets.ORACLE_COMPUTE_HOST_817 }}:~/hr-jars/app.jar | |
- name: Restart application | |
run: | | |
ssh -i ./deploy_key -o "StrictHostKeyChecking=no" opc@${{ secrets.ORACLE_COMPUTE_HOST_817 }} 'sudo chmod +x $HOME/hr-jars/app.jar' | |
ssh -i ./deploy_key -o "StrictHostKeyChecking=no" opc@${{ secrets.ORACLE_COMPUTE_HOST_817 }} 'sudo systemctl restart hr_app.service' |