Merge pull request #5 from FoodCoopV3/main #29
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: CI | |
on: | |
# Triggers the workflow on push or pull request events but only for the master branch | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
# Allows you to run this workflow manually from the Actions tab | |
workflow_dispatch: | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 11 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '11' | |
distribution: 'adopt' | |
- name: Create Application.Properties | |
run: | | |
printf "$DEV_ENV_FILE" >> plugins/src/main/resources/application.properties | |
cat plugins/src/main/resources/application.properties | |
env: | |
DEV_ENV_FILE : ${{secrets.APPLICATION_PROPERTIES}} | |
- name: clean install | |
run: mvn clean install | |
- name: Build with Maven | |
run: mvn --batch-mode --update-snapshots package | |
- name: Modify files permissions | |
run: | | |
chmod 777 -R ./plugins | |
ls -l | |
- name: Install SSH Key | |
uses: shimataro/ssh-key-action@v2 | |
with: | |
key: ${{ secrets.SSH_PRIVATE_KEY }} | |
known_hosts: 'just-a-placeholder-so-we-dont-get-errors' | |
- name: Adding Known Hosts | |
run: ssh-keyscan -p ${{ secrets.SSH_PORT }} -H ${{ secrets.SSH_HOST }} >> ~/.ssh/known_hosts | |
- name: Deploy Jar with rsync | |
run: rsync -avz -e "ssh -p ${{ secrets.SSH_PORT }}" ./plugins/target/plugins-1.0-SNAPSHOT-exec.jar ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/volume1/FoodCoop_Share/backend-installation/ | |
- name: Deploy Dockerfile with rsync | |
run: rsync -avz -e "ssh -p ${{ secrets.SSH_PORT }}" ./Dockerfile ${{ secrets.SSH_USER }}@${{ secrets.SSH_HOST }}:/volume1/FoodCoop_Share/backend-installation/ | |
- name: stop old conatiner | |
uses: fifsky/ssh-action@master | |
with: | |
command: | | |
cd /volume1/FoodCoop_Share/backend-installation/ | |
echo "${{ secrets.SSH_SUDOPW }}" | sudo -S docker ps -q --filter ancestor=foodcoop/backend | xargs sudo docker stop | |
sleep 15 | |
host: ${{ secrets.SSH_HOST }} | |
user: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY}} | |
port: ${{ secrets.SSH_PORT }} | |
- name: Override container | |
uses: fifsky/ssh-action@master | |
with: | |
command: | | |
cd /volume1/FoodCoop_Share/backend-installation/ | |
sleep 15 | |
echo "${{ secrets.SSH_SUDOPW }}" | sudo -S docker rmi -f foodcoop/backend | |
echo "${{ secrets.SSH_SUDOPW }}" | sudo -S docker build -t foodcoop/backend . | |
echo "${{ secrets.SSH_SUDOPW }}" | sudo -S docker run -d -p 8080:8080 foodcoop/backend | |
exit 0 | |
host: ${{ secrets.SSH_HOST }} | |
user: ${{ secrets.SSH_USER }} | |
key: ${{ secrets.SSH_PRIVATE_KEY}} | |
port: ${{ secrets.SSH_PORT }} |