-
Notifications
You must be signed in to change notification settings - Fork 1
88 lines (79 loc) · 2.74 KB
/
deploy.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
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
name: Deploy image to Docker Hub
on:
push:
branches:
- master
pull_request:
jobs:
check_skip_flags:
name: Check skip flags
runs-on: ubuntu-latest
outputs:
head-commit-message: ${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}
steps:
- name: Checkout Commit
uses: actions/checkout@v3
with:
ref: ${{ env.GITHUB_SHA }}
- name: Get Head Commit Message
id: get_head_commit_message
run: echo "HEAD_COMMIT_MESSAGE=$(git show -s --format=%s)" >> "$GITHUB_OUTPUT"
- name: Debug Commit Message
run: |
echo "Commit Message= ${{ steps.get_head_commit_message.outputs.HEAD_COMMIT_MESSAGE }}"
echo "Head_commit_message = $HEAD_COMMIT_MESSAGE"
echo "Github Output = $GITHUB_OUTPUT"
echo "Github Sha = ${{ env.GITHUB_SHA }}"
echo "Github event = ${{ github.event.head_commit.message }}"
echo "Github event[0] = ${{ github.event.commits[0].message }}"
echo "Github commit = $(git log -1 --no-merges --pretty=%B)"
echo "Github ENV = $GITHUB_ENV"
build-and-push-docker-image:
runs-on: ubuntu-latest
needs: check_skip_flags
if: |
github.event_name == 'push' || (
github.event_name == 'pull_request' &&
contains(${{ github.event.head_commit.message }}, '[push image]')
)
steps:
- name: Checkout repository
uses: actions/checkout@v2
- name: Debug Commit Message
run: echo "Commit Message= ${{ needs.check_skip_flags.outputs.head-commit-message }}"
# - name: Set up JDK
# uses: actions/setup-java@v4
# with:
# distribution: 'temurin'
# java-version: '17'
#
# - name: Build with Gradle
# run: ./gradlew clean build
#
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
#
# - name: Login to Docker Hub
# uses: docker/login-action@v1
# with:
# username: ${{ secrets.DOCKER_USERNAME }}
# password: ${{ secrets.DOCKER_PASSWORD }}
#
# - name: Determine Docker Tag [branch_name/latest]
# id: docker_tag
# run: |
# if [ -n "$GITHUB_HEAD_REF" ]; then
# echo "Setting tag to branch name: $GITHUB_HEAD_REF"
# echo "::set-output name=tag::$GITHUB_HEAD_REF"
# else
# echo "Setting tag to 'latest'"
# echo "::set-output name=tag::latest"
# fi
#
# - name: Build and push Docker image
# env:
# DOCKER_REPO: viepovsky/car-service-garage-backend
# DOCKER_TAG: ${{ steps.docker_tag.outputs.tag }}
# run: |
# docker buildx create --use
# docker buildx build -t $DOCKER_REPO:$DOCKER_TAG --push .