-
Notifications
You must be signed in to change notification settings - Fork 0
82 lines (72 loc) · 2.55 KB
/
ci: Build-Frontend-Services.yaml
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
name: CI Docker Build and Push for Frontend Services
on:
push:
branches:
- main
- develop
pull_request:
branches:
- main
- develop
workflow_dispatch: # Manual trigger
inputs:
RELEASE_VERSION:
description: 'Release version (e.g., 1.0.0). The "v" prefix will be automatically added.'
required: false
default: ''
jobs:
ci-build:
name: CI Docker Build
runs-on: ubuntu-latest
if: github.event_name != 'workflow_dispatch' # Only run on push or PR, skip manual dispatch
steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Step 2: Set up Docker Image Tag
- name: Set up Docker Image Tag
id: tag_step
run: |
DATE_TAG="v$(date +'%Y.%m.%d')"
# Create a default tag for CI builds that isn't meant to be pushed
NEW_TAG="${DATE_TAG}-ci"
echo "Docker Tag: ${NEW_TAG}"
echo "::set-output name=tag::${NEW_TAG}"
# Step 3: Build Docker Image (without push)
- name: Build Docker Image (No Push)
uses: docker/build-push-action@v5
with:
context: ./infra_env_dashboard/frontend # Correct context for Dockerfile location
push: false
tags: |
sam123ben/infra-dashboard:${{ steps.tag_step.outputs.tag }}
manual-build-push:
name: Manual Docker Build and Push
runs-on: ubuntu-latest
if: github.event_name == 'workflow_dispatch' # Only run on manual trigger
steps:
# Step 1: Checkout the repository
- name: Checkout Repository
uses: actions/checkout@v3
# Step 2: Validate Release Version
- name: Validate Release Version
run: |
if [ -z "${{ github.event.inputs.RELEASE_VERSION }}" ]; then
echo "Error: Please provide a valid release version for manual build and push."
exit 1
fi
# Step 3: Log in to Docker Hub using the Access Token
- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_HUB_PAT_TOKEN }}
# Step 4: Build and Push Docker Image
- name: Build and Push Docker Image
uses: docker/build-push-action@v5
with:
context: ./infra_env_dashboard/frontend # Correct context for Dockerfile location
push: true
tags: |
sam123ben/infra-dashboard:latest
sam123ben/infra-dashboard:${{ github.event.inputs.RELEASE_VERSION }}