Skip to content

Commit

Permalink
Update cicd-dev.yml
Browse files Browse the repository at this point in the history
  • Loading branch information
linglong67 authored Feb 2, 2024
1 parent dde2526 commit 95139e3
Showing 1 changed file with 53 additions and 53 deletions.
106 changes: 53 additions & 53 deletions .github/workflows/cicd-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: CI and CD in WashPedia Project

on:
push:
branches: [ "develop" ]
branches: [ "feature/develop-deploy-in-vultr" ]

permissions:
contents: read
Expand Down Expand Up @@ -42,12 +42,12 @@ jobs:
env:
spring.profiles.active: "dev"

- name: Set application yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application.yml
env:
spring.profiles.active: "dev"
# - name: Set application yml file (batch)
# uses: microsoft/variable-substitution@v1
# with:
# files: ./module-batch/src/main/resources/application.yml
# env:
# spring.profiles.active: "dev"

- name: Set application-dev yml file (api)
uses: microsoft/variable-substitution@v1
Expand All @@ -58,28 +58,28 @@ jobs:
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}

- name: Set application-dev yml file (batch)
uses: microsoft/variable-substitution@v1
with:
files: ./module-batch/src/main/resources/application-dev.yml
env:
spring.datasource.url: ${{ secrets.DB_URL }}
spring.datasource.username: ${{ secrets.DB_USER }}
spring.datasource.password: ${{ secrets.DB_PW }}
external.ecolife-api.path: ${{ secrets.ECOLIFE_PATH }}
external.ecolife-api.service-key: ${{ secrets.ECOLIFE_KEY }}
# - name: Set application-dev yml file (batch)
# uses: microsoft/variable-substitution@v1
# with:
# files: ./module-batch/src/main/resources/application-dev.yml
# env:
# spring.datasource.url: ${{ secrets.DB_URL }}
# spring.datasource.username: ${{ secrets.DB_USER }}
# spring.datasource.password: ${{ secrets.DB_PW }}
# external.ecolife-api.path: ${{ secrets.ECOLIFE_PATH }}
# external.ecolife-api.service-key: ${{ secrets.ECOLIFE_KEY }}

- name: Grant execute permission And Build with Gradle (api)
working-directory: ./module-api
run: |
chmod +x ./gradlew
./gradlew clean build
- name: Grant execute permission And Build with Gradle (batch)
working-directory: ./module-batch
run: |
chmod +x ./gradlew
./gradlew clean build
# - name: Grant execute permission And Build with Gradle (batch)
# working-directory: ./module-batch
# run: |
# chmod +x ./gradlew
# ./gradlew clean build

- name: DockerHub Login
uses: docker/login-action@v2
Expand All @@ -90,35 +90,35 @@ jobs:
- name: Docker Image Build And Push (api)
working-directory: ./module-api
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }}
- name: Docker Image Build And Push (batch)
working-directory: ./module-batch
run: |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }} . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }}
- name: Application Run
uses: appleboy/[email protected]
with:
host: ${{ secrets.VULTR_IP }}
username: ${{ secrets.VULTR_USERNAME }}
password: ${{ secrets.VULTR_PW }}
script: |
# Install Docker and Docker Compose
dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
dnf install -y docker-ce docker-ce-cli containerd.io
systemctl start docker
systemctl enable docker
curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
chmod +x /usr/local/bin/docker-compose
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }}2 . --platform=linux/amd64
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_API_NAME }}2
# - name: Docker Image Build And Push (batch)
# working-directory: ./module-batch
# run: |
# docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }} . --platform=linux/amd64
# docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ secrets.MODULE_BATCH_NAME }}

# - name: Application Run
# uses: appleboy/[email protected]
# with:
# host: ${{ secrets.VULTR_IP }}
# username: ${{ secrets.VULTR_USERNAME }}
# password: ${{ secrets.VULTR_PW }}
# script: |
# # Install Docker and Docker Compose
# dnf config-manager --add-repo=https://download.docker.com/linux/centos/docker-ce.repo
# dnf install -y docker-ce docker-ce-cli containerd.io
# systemctl start docker
# systemctl enable docker
# curl -L "https://github.com/docker/compose/releases/latest/download/docker-compose-$(uname -s)-$(uname -m)" -o /usr/local/bin/docker-compose
# chmod +x /usr/local/bin/docker-compose

# Docker Compose
mkdir -p deploy
cd deploy
echo "${{ secrets.DB_INIT_SQL }}" > init.sql
echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml
docker-compose pull
docker-compose down
docker-compose up -d
# # Docker Compose
# mkdir -p deploy
# cd deploy
# echo "${{ secrets.DB_INIT_SQL }}" > init.sql
# echo "${{ secrets.DOCKER_COMPOSE }}" > docker-compose.yml
# docker-compose pull
# docker-compose down
# docker-compose up -d

0 comments on commit 95139e3

Please sign in to comment.