Skip to content

[기타] git actions test 9 #10

[기타] git actions test 9

[기타] git actions test 9 #10

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.get-latest-tag.outputs.tag }}
steps:
- name: git checkout local
uses: actions/checkout@v2
- 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@v3
- 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 build
run: ./gradlew clean build
- name: build docker
run: ./gradlew bootBuildImage --imageName=${{ github.event.repository.name }}
- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Docker push
run: |
docker tag ${{ github.event.repository.name }}:${{needs.ifMergedTag.outputs.tagVersion}} ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{needs.ifMergedTag.outputs.tagVersion}}
docker push ${{ secrets.DOCKERHUB_USERNAME }}/${{ github.event.repository.name }}:${{needs.ifMergedTag.outputs.tagVersion}}