-
Notifications
You must be signed in to change notification settings - Fork 0
69 lines (56 loc) · 2.07 KB
/
git-tag-image-push.yml
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
name: github action tag
permissions:
contents: write
on:
pull_request:
types:
- closed
jobs:
ifMergedTag:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
outputs:
tagVersion: ${{ steps.bump-semver.outputs.new_version }}
steps:
- name: git checkout local
uses: actions/checkout@v4
- name: get latest tag from local git
uses: actions-ecosystem/action-get-latest-tag@v1
id: get-latest-tag
- name: plus minor version
uses: actions-ecosystem/action-bump-semver@v1
id: bump-semver
with:
current_version: ${{ steps.get-latest-tag.outputs.tag }}
level: patch
- name: push tag to github origin main
uses: actions-ecosystem/action-push-tag@v1
with:
tag: ${{ steps.bump-semver.outputs.new_version }}
message: '${{ steps.bump-semver.outputs.new_version }}: PR #${{ github.event.pull_request.number }} ${{ github.event.pull_request.title }}'
buildAndPushImageToDockerHub:
if: github.event.pull_request.merged == true
runs-on: ubuntu-latest
needs: ifMergedTag
steps:
- uses: actions/checkout@v4
- name: Set up JDK 17
uses: actions/setup-java@v3
with:
java-version: '17'
distribution: 'temurin'
# gradle 빌드 실행을 위한 권한을 부여
- name: grant execute permission for gradlew
run: chmod +x gradlew
- name: gradle cleana and build image
run: ./gradlew clean bootBuildImage --imageName=docker.io/preference112/super-sns
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Push images
run: |
docker tag preference112/super-sns:latest preference112/super-sns:${{ needs.ifMergedTag.outputs.tagVersion }}
docker push preference112/super-sns:${{ needs.ifMergedTag.outputs.tagVersion }}
docker push preference112/super-sns:latest