Skip to content

Commit

Permalink
chore: Deploy automatically with tags (#6)
Browse files Browse the repository at this point in the history
  • Loading branch information
nicopico-dev authored Feb 25, 2024
1 parent 5b73f95 commit cc1989b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 2 deletions.
File renamed without changes.
38 changes: 38 additions & 0 deletions .github/workflows/deploy-on-tag.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
name: CD - Deploy on Tags

on:
push:
tags:
- '*.*.*'

jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- name: Set up Java
uses: actions/setup-java@v2
with:
java-version: '17'
distribution: 'adopt'
- name: Setup Gradle cache
uses: actions/cache@v2
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: Build application JAR
run: ./gradlew --no-daemon bootJar copyJarToDeploy
- name: Deploy to server
uses: SamKirkland/[email protected]
with:
server: ${{ secrets.FTP_SERVER }}
username: ${{ secrets.FTP_USERNAME }}
password: ${{ secrets.FTP_PASSWORD }}
server-dir: ${{ env.FTP_DIR }}
local-dir: ./deploy/
4 changes: 2 additions & 2 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -71,13 +71,13 @@ tasks.withType<Test> {
useJUnitPlatform()
}

val copyJar by tasks.registering(Copy::class) {
val copyJarToDeploy by tasks.registering(Copy::class) {
val bootJar = tasks.getByName("bootJar") as
org.springframework.boot.gradle.tasks.bundling.BootJar
from(bootJar.archiveFile)
into(project.layout.projectDirectory.dir("deploy"))
rename { "n2rss.jar" }
}
tasks.named("build") {
finalizedBy(copyJar)
finalizedBy(copyJarToDeploy)
}

0 comments on commit cc1989b

Please sign in to comment.