-
Notifications
You must be signed in to change notification settings - Fork 0
65 lines (59 loc) · 1.69 KB
/
ci-cd.yml
File metadata and controls
65 lines (59 loc) · 1.69 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
name: Build and Deploy
on:
push:
branches:
- main
workflow_dispatch:
inputs:
force:
description: 'Force exec'
type: boolean
required: true
jobs:
Detect:
runs-on: ubuntu-latest
outputs:
app: ${{ steps.detect.outputs.app }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- name: Detect Change
id: detect
run: |
APP="${GITHUB_REPOSITORY#*/}"
CHANGE_FILES=`git diff --no-commit-id --name-only HEAD^`
CHANGED=`echo "$CHANGE_FILES" | grep -Em 1 "dockerfile" || true`
if [ -z "$CHANGED" ] && [ "${{ inputs.force }}" != true ]; then
APP=""
fi
echo "app=${APP}" >> $GITHUB_OUTPUT
Build:
name: "Build ${{ needs.Detect.outputs.app }}"
needs: Detect
if: needs.Detect.outputs.app != ''
runs-on: ubuntu-latest
env:
app: ${{ needs.Detect.outputs.app }}
steps:
- uses: actions/checkout@v4
with:
fetch-depth: 0
- id: envs
uses: netcorext/base-info-action@dev
with:
app: ${{ env.app }}
version: 1.0.0
image-prefix: ${{ vars.IMAGE_PREFIX }}
- name: Login to DockerHub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build Image & Push
uses: netcorext/buildx-image-action@dev
with:
image: ${{ steps.envs.outputs.image-fullName }}
tag: ${{ steps.envs.outputs.tag }}
tag-hash: ${{ steps.envs.outputs.tag-hash }}
tag-latest: ${{ steps.envs.outputs.tag-latest }}