5/12: migrate upload file to cloudinary #8
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
on: | |
push: | |
branches: [ "master" ] | |
pull_request: | |
branches: [ "master" ] | |
jobs: | |
build: | |
runs-on: [ubuntu-latest] | |
steps: | |
- name: Checkout source | |
uses: actions/checkout@v3 | |
- name: Setup Java | |
uses: actions/setup-java@v3 | |
with: | |
distribution: 'temurin' | |
java-version: '17' | |
- name: Login to DockerHub | |
run: docker login -u ${{secrets.DOCKER_USERNAME}} -p ${{secrets.DOCKER_PASSWORD}} | |
- name: Build project and push to dockerhub | |
run: mvn clean install jib:build | |
deploy: | |
needs: build | |
runs-on: [ azure ] | |
steps: | |
- name: Check if directory exists | |
id: check_directory | |
run: | | |
if [ -d spotify ]; then | |
echo "Directory 'spotify' exists." | |
echo "::set-output name=directory_exists::true" | |
else | |
echo "Directory 'spotify' does not exist." | |
echo "::set-output name=directory_exists::false" | |
fi | |
- name: Clone or update repository | |
if: steps.check_directory.outputs.directory_exists == 'false' | |
run: | | |
git clone ${{secrets.GIT_REPO_SPOTIFY}} spotify | |
cd spotify | |
echo "Current Directory: $(pwd)" | |
- name: Remove existing directory and clone again | |
if: steps.check_directory.outputs.directory_exists == 'true' | |
run: | | |
sudo rm -rf spotify | |
git clone ${{secrets.GIT_REPO_SPOTIFY}} spotify | |
cd spotify | |
echo "Current Directory: $(pwd)" | |
ls | |
# - name: Check if Docker Compose project is running | |
# id: check_docker_compose | |
# run: | | |
# if docker-compose --project-name spotify-server ps | grep -q "Up"; then | |
# echo "Docker Compose project 'spotify-server' is running." | |
# echo "::set-output name=docker_compose_running::true" | |
# else | |
# echo "Docker Compose project 'spotify-server' is not running." | |
# echo "::set-output name=docker_compose_running::false" | |
# fi | |
# | |
# - name: Stop and remove Docker Compose project if running | |
# if: steps.check_docker_compose.outputs.docker_compose_running == 'true' | |
# run: | | |
# sudo docker compose --project-name spotify-server down | |
# | |
# - name: Run server with Docker Compose | |
# run: sudo docker compose --project-name spotify-server up | |