Skip to content

Commit e4bf211

Browse files
committed
CI git tag version
1 parent 054a344 commit e4bf211

4 files changed

Lines changed: 14 additions & 5 deletions

File tree

‎.github/workflows/deploy.yml‎

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@ jobs:
88
deploy:
99
runs-on: ubuntu-latest
1010
environment: production
11+
env:
12+
APP_VERSION: ${{ github.event.release.tag_name }}
1113

1214
steps:
1315
- name: Checkout repository
@@ -33,13 +35,15 @@ jobs:
3335
echo "tomcat.url=${{ secrets.SERVER_URL }}" >> $GITHUB_ENV
3436
echo "tomcat.user=${{ secrets.TOMCAT_USERNAME }}" >> $GITHUB_ENV
3537
echo "tomcat.password=${{ secrets.TOMCAT_PASSWORD }}" >> $GITHUB_ENV
38+
echo "app.version=${APP_VERSION}" > src/main/resources/version.properties
3639
3740
- name: Deploy to Tomcat
3841
run: mvn tomcat7:deploy -DskipTests
3942
env:
43+
APP_VERSION: ${{ env.APP_VERSION }}
4044
SERVER_URL: ${{ secrets.SERVER_URL }}
4145
TOMCAT_USERNAME: ${{ secrets.TOMCAT_USERNAME }}
4246
TOMCAT_PASSWORD: ${{ secrets.TOMCAT_PASSWORD }}
4347
BOT_DB_URL: ${{ secrets.BOT_DB_URL }}
4448
BOT_DB_USER: ${{ secrets.BOT_DB_USER }}
45-
BOT_DB_PASS: ${{ secrets.BOT_DB_PASS }}
49+
BOT_DB_PASS: ${{ secrets.BOT_DB_PASS }}

‎src/main/java/ru/flashcards/telegram/Application.java‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,14 @@
44
import org.springframework.boot.autoconfigure.SpringBootApplication;
55
import org.springframework.boot.context.properties.EnableConfigurationProperties;
66
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
7+
import org.springframework.context.annotation.PropertySource;
78
import org.springframework.scheduling.annotation.EnableScheduling;
89
import ru.flashcards.telegram.bot.config.TelegramProperties;
910

1011
@SpringBootApplication
1112
@EnableScheduling
1213
@EnableConfigurationProperties(TelegramProperties.class)
14+
@PropertySource("classpath:version.properties")
1315
public class Application extends SpringBootServletInitializer {
1416
public static void main(String[] args) {
1517
SpringApplication.run(Application.class, args);

‎src/main/java/ru/flashcards/telegram/bot/controller/WebhookController.java‎

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import lombok.AllArgsConstructor;
66
import org.slf4j.Logger;
77
import org.slf4j.LoggerFactory;
8+
import org.springframework.core.env.Environment;
89
import org.springframework.http.HttpStatus;
910
import org.springframework.http.ResponseEntity;
1011
import org.springframework.web.bind.annotation.GetMapping;
@@ -33,6 +34,7 @@ public class WebhookController {
3334
private MessageFactoryProvider messageFactoryProvider;
3435
private CallbackFactoryProvider callbackFactoryProvider;
3536
private UserModeSettings userModeSettings;
37+
private Environment environment;
3638

3739
@PostMapping("/webhook")
3840
public void onUpdateReceived(@RequestBody Update update) {
@@ -46,9 +48,9 @@ public void onUpdateReceived(@RequestBody Update update) {
4648
logger.error("Internal error", e);
4749
}
4850
}
49-
@GetMapping("/test")
50-
public ResponseEntity<String> test() {
51-
return ResponseEntity.status(HttpStatus.OK).body("1.3.4");
51+
@GetMapping("/version")
52+
public ResponseEntity<String> version() {
53+
return ResponseEntity.status(HttpStatus.OK).body(environment.getProperty("app.version", "unknown"));
5254
}
5355

5456
private List<BotApiMethod<?>> handleMessageInput(Message message) {
@@ -98,4 +100,4 @@ private void execute(List<BotApiMethod<?>> response) {
98100
}
99101
});
100102
}
101-
}
103+
}
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
app.version=local

0 commit comments

Comments
 (0)