-
Notifications
You must be signed in to change notification settings - Fork 3
86 lines (85 loc) · 2.58 KB
/
deploy.yml
File metadata and controls
86 lines (85 loc) · 2.58 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
name: Build and Push Docker Image
on:
push:
paths:
- '.github/workflows/**'
- 'backend/src/**'
- 'backend/build.gradle'
- 'backend/Dockerfile'
branches:
- dev
jobs:
build:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
outputs:
tag_name: ${{ steps.create_tag.outputs.new_tag }}
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up JDK 21
uses: actions/setup-java@v3
with:
java-version: '21'
distribution: 'temurin'
cache: gradle
- name: Build with Gradle
run: |
cd backend
mkdir -p src/main/resources/
mkdir -p src/test/resources/
echo "${{ secrets.APPLICATION_DEV_YML }}" > src/main/resources/application-dev.yml
echo "${{ secrets.APPLICATION_TEST_YML }}" > src/test/resources/application.yml
chmod +x gradlew
./gradlew bootJar
- name: Create Tag
id: create_tag
uses: mathieudutour/github-tag-action@v6.2
with:
github_token: ${{ secrets.REPOSITORY_TOKEN }}
- name: Create Release
uses: actions/create-release@v1
env:
GITHUB_TOKEN: ${{ secrets.REPOSITORY_TOKEN }}
with:
tag_name: ${{ steps.create_tag.outputs.new_tag }}
release_name: Release ${{ steps.create_tag.outputs.new_tag }}
body: ${{ steps.create_tag.outputs.changelog }}
draft: false
prerelease: false
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.REPOSITORY_TOKEN }}
- name: Extract metadata for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: ghcr.io/${{ github.repository }}/backend
tags: |
latest
${{ needs.makeTagAndRelease.outputs.tag_name }}
- name: Build and push Docker image
uses: docker/build-push-action@v4
with:
context: ./backend
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
platforms: linux/amd64,linux/arm64
- name: Jenkins deploy
if: success()
uses: appleboy/jenkins-action@master
with:
url: ${{ secrets.JENKINS_URL }}
user: ${{ secrets.JENKINS_USER }}
token: ${{ secrets.JENKINS_DEPLOY_TOKEN }}
job: ${{ secrets.JENKINS_JOB }}