Action test #3
Workflow file for this run
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
name: CD | |
on: | |
push: | |
branches: [ "cd" ] | |
pull_request: | |
branches: [ "main" ] | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Set up JDK 17 | |
uses: actions/setup-java@v3 | |
with: | |
java-version: '17' | |
distribution: 'temurin' | |
- name: Gradle Caching | |
uses: actions/cache@v3 | |
with: | |
path: | | |
~/.gradle/caches | |
~/.gradle/wrapper | |
key: ${{ runner.os }}-gradle-${{ hashFiles('**/*.gradle*', '**/gradle-wrapper.properties') }} | |
restore-keys: | | |
${{ runner.os }}-gradle- | |
- name: Grant execute permission for gradlew | |
run: chmod +x gradlew | |
- name: Create application.yml | |
run: | | |
cd ./src/main/resources | |
touch ./application.yml | |
echo "${{ secrets.APPLICATION }}" > ./application.yml | |
shell: bash | |
- name: Access permission to gradle build | |
run: chmod +x gradlew | |
- name: Run gradle build | |
run: ./gradlew build | |
shell: bash | |
- name: Build docker image build and push | |
run: | | |
docker login -u ${{ secrets.DOCKER_USERNAME }} -p ${{ secrets.DOCKER_PASSWORD }} | |
docker build -t ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} . | |
docker push ${{ secrets.DOCKER_REPOSITORY }}/${{ secrets.DOCKER_IMAGE }} | |
- name: Pull from docker hub and deploy | |
uses: appleboy/ssh-action@master | |
with: | |
username: ${{ secrets.REMOTE_USERNAME }} | |
host: ${{ secrets.REMOTE_HOST }} | |
key: ${{ secrets.REMOTE_KEY }} | |
script: | | |
cd /Backend | |
sudo docker compose down | |
sudo docker compose up -d |