2024-06-06 06:30:13 +02:00
|
|
|
name: Build docker images, publish them, deploy to test server
|
2024-05-30 04:20:39 +02:00
|
|
|
|
|
|
|
on:
|
|
|
|
push:
|
|
|
|
branches: ["dev"]
|
|
|
|
|
2024-05-30 05:20:35 +02:00
|
|
|
|
2024-05-30 04:20:39 +02:00
|
|
|
jobs:
|
|
|
|
build:
|
|
|
|
runs-on: ubuntu-latest
|
|
|
|
|
|
|
|
steps:
|
2024-05-31 08:56:58 +02:00
|
|
|
- name: Restore cached Primes
|
|
|
|
id: maven-cache-restore
|
|
|
|
uses: https://github.com/actions/cache/restore@v4
|
|
|
|
with:
|
2024-06-01 19:27:37 +02:00
|
|
|
key: linux-maven
|
2024-05-31 08:56:58 +02:00
|
|
|
|
2024-05-30 05:20:35 +02:00
|
|
|
- uses: https://github.com/actions/checkout@v4
|
2024-05-30 05:29:27 +02:00
|
|
|
with:
|
|
|
|
repository: 'learningpulse/server'
|
|
|
|
ref: 'dev'
|
|
|
|
token: '${{ secrets.token }}'
|
2024-05-31 08:56:58 +02:00
|
|
|
|
2024-05-30 05:57:47 +02:00
|
|
|
- name: 'Set up java 22'
|
2024-05-31 08:31:39 +02:00
|
|
|
uses: https://github.com/actions/setup-java@v4
|
2024-05-30 04:20:39 +02:00
|
|
|
with:
|
2024-05-30 06:06:43 +02:00
|
|
|
java-version: "22"
|
2024-05-30 06:02:53 +02:00
|
|
|
distribution: "temurin"
|
2024-05-30 06:06:43 +02:00
|
|
|
|
2024-05-31 08:56:58 +02:00
|
|
|
- name: Setup maven
|
|
|
|
if: steps.maven-cache.outputs.cache-hit != 'true'
|
|
|
|
uses: https://github.com/stCarolas/setup-maven@v5
|
|
|
|
with:
|
|
|
|
maven-version: 3.9.6
|
|
|
|
|
2024-05-31 09:33:14 +02:00
|
|
|
- name: Build with Maven
|
|
|
|
run: mvn -Dtoken=${{ secrets.token }} clean compile jib:build -e
|
|
|
|
|
2024-05-31 08:56:58 +02:00
|
|
|
- name: Cache local Maven repository
|
|
|
|
uses: https://github.com/actions/cache/save@v4
|
|
|
|
id: maven-cache-save
|
|
|
|
with:
|
|
|
|
path: ~/.m2/repository
|
2024-06-01 19:26:30 +02:00
|
|
|
key: linux-maven
|
2024-05-31 08:56:58 +02:00
|
|
|
restore-keys: |
|
2024-06-01 19:26:30 +02:00
|
|
|
linux-maven
|
2024-06-06 06:30:13 +02:00
|
|
|
|
|
|
|
# TODO trigger pull with docker
|
2024-06-01 19:06:48 +02:00
|
|
|
- name: executing remote ssh commands using ssh key
|
|
|
|
uses: https://github.com/appleboy/ssh-action@v1.0.3
|
2024-06-01 18:47:05 +02:00
|
|
|
with:
|
2024-06-01 19:06:48 +02:00
|
|
|
host: ${{ secrets.HOST }}
|
|
|
|
username: ${{ secrets.USERNAME }}
|
|
|
|
key: ${{ secrets.KEY }}
|
|
|
|
port: ${{ secrets.PORT }}
|
2024-06-01 19:30:09 +02:00
|
|
|
script: cd services/server && git fetch --all && git reset --hard origin/dev && docker compose pull && docker compose up -d
|