Skip to content

fix: build-and-push #33

fix: build-and-push

fix: build-and-push #33

Workflow file for this run

name: ci-cd develop
on:
push:
branches:
- develop
pull_request:
types: [ closed ]
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v3
- name: checkout source code
uses: actions/checkout@v3
with:
submodules: true
token: ${{ secrets.ACTION_SECRETS}}
- name: set up JDK 17
uses: actions/setup-java@v3
with:
java-version: 17
distribution: 'zulu'
- name: copy application.yml files from submodule
run: |
mkdir -p src/main/resources
cp -r BE-hubo-gillajabi-resources/resources/application*.yml src/main/resources/
- name: Grant execute permission for gradlew
run: chmod +x ./gradlew
- name: bootJar with gradle
run: ./gradlew bootJar
- name: update release
uses: release-drafter/release-drafter@v6
with:
config-name: release-drafter.yml
env:
GITHUB_TOKEN: ${{ secrets.ACTION_SECRETS }}
prerelease-identifier: 'dev'
- name: set docker tag
id: docker_tag
run: |
if [ "${{ github.event_name }}" == "push" ]; then
TAG=$(curl -sH "Authorization: token ${{ secrets.ACTION_SECRETS }}" \
https://api.github.com/repos/${{ github.repository }}/releases?per_page=1 | jq -r 'map(select(.draft == true)) | .[0].tag_name')
if [ "$TAG" == "null" ]; then
TAG="${{ github.sha }}"
fi
elif [ "${{ github.event_name }}" == "release" ]; then
TAG="${{ github.event.release.tag_name }}"
else
TAG="latest"
fi
echo "TAG=$TAG" >> $GITHUB_ENV
- name: docker login
uses: docker/login-action@v3.1.0
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_LOGIN_TOKEN }}
- name: build and push
run: |
docker build -f Dockerfile-dev --platform linux/amd64 -t ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.PROJECT_NAME }}:$TAG .
docker push ${{ secrets.DOCKER_HUB_USERNAME }}/${{ secrets.PROJECT_NAME }}:$TAG
deploy:
needs: build
runs-on: ubuntu-latest
steps:
- name: checkout source code
uses: appleboy/ssh-action@master
with:
host: ${{ secrets.BE_HOST }}
username: ${{ secrets.BE_USER }}
port: ${{ secrets.BE_PORT }}
password: ${{ secrets.BE_PW }}
script: |
cd hubo
sudo docker-compose down
sudo docker-compose pull
sudo docker-compose up -d