Skip to content

Deploy service after action finishes on main #58

Deploy service after action finishes on main

Deploy service after action finishes on main #58

Workflow file for this run

name: CI
on:
push:
branches: [ "main" ]
pull_request:
branches: [ "main" ]
jobs:
build:
name: Build
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'corretto'
- name: Set up Gradle
uses: gradle/gradle-build-action@v2
id: setup-gradle
with:
gradle-version: 8.3
- name: Build
run: gradle build -i
- name: Unit Tests
run: gradle runUnitTests -i
- name: Integration Tests
run: gradle runIntegrationTests -i
- name: Build Image
run: docker build -t maezzedine/personal-space:latest -t maezzedine/personal-space:${{ github.run_number }} .
- name: Login to Docker Hub
uses: docker/login-action@v1
if: github.event_name == 'push'
with:
username: maezzedine
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Publish Images
if: github.event_name == 'push'
run: docker push maezzedine/personal-space --all-tags
- name: Deploy
uses: appleboy/ssh-action@master
if: github.event_name == 'push'
with:
host: ${{ secrets.DEPLOYMENT_HOST }}
username: ${{ secrets.DEPLOYMENT_USERNAME }}
key: ${{ secrets.DEPLOYMENT_PRIVATE_KEY }}
script: |
cd devops
./docker-redeploy.sh
echo 'Deployment finished'