Skip to content

♻️ extract variable and rename constant #23

♻️ extract variable and rename constant

♻️ extract variable and rename constant #23

Workflow file for this run

name: Backend CD Develop
on:
push:
branches:
- be/dev
concurrency:
group: ${{ github.ref }}
cancel-in-progress: true
jobs:
build:
runs-on: ubuntu-latest
environment: test
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Set up JDK 21
uses: actions/setup-java@v4
with:
java-version: 21
distribution: temurin
cache: gradle
- name: Cache Gradle
uses: actions/cache@v4
with:
path: |
~/.gradle/caches
~/.gradle/wrapper
key: ${{ runner.os }}-gradle-${{ hashFiles('**/build.gradle') }}
restore-keys: |
${{ runner.os }}-gradle-
- name: Add execute permissions
working-directory: ./backend
run: chmod +x ./gradlew
- name: Build
working-directory: ./backend
run: ./gradlew build -x test -x bootJar
- name: Test and Create OAS
env:
JASYPT_PASSWORD: ${{ secrets.JASYPT_PASSWORD }}
working-directory: ./backend
run: ./gradlew copyOasToSwagger
- name: Create bootJar
working-directory: ./backend
run: ./gradlew bootJar
- name: Build Docker image
working-directory: ./backend
run: |
docker build \
-f Dockerfile-dev \
-t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:dev \
.
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push Docker image
run: docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.DOCKERHUB_IMAGE_NAME }}:dev
deploy:
needs: build
runs-on: ubuntu-latest
environment: dev
steps:
- name: Checkout Repository
uses: actions/checkout@v4
- name: Send docker compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
strip_components: 2
source: backend/docker/docker-compose-dev.yaml
target: ~/${{ github.event.repository.name }}
- name: Rename docker compose file
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/${{ github.event.repository.name }}
mv docker-compose-dev.yaml docker-compose.yaml
- name: Set up environment variables
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/${{ github.event.repository.name }}
echo "MYSQL_DATABASE=${{ secrets.MYSQL_DATABASE }}" > .env
echo "MYSQL_ROOT_PASSWORD=${{ secrets.MYSQL_ROOT_PASSWORD }}" >> .env
echo "JASYPT_PASSWORD=${{ secrets.JASYPT_PASSWORD }}" >> .env
- name: Run new docker compose
uses: appleboy/[email protected]
with:
host: ${{ secrets.SSH_HOST }}
username: ${{ secrets.SSH_USERNAME }}
key: ${{ secrets.SSH_KEY }}
script: |
cd ~/${{ github.event.repository.name }}
docker compose pull
docker compose down
docker compose up -d
docker image prune -af