Skip to content

Commit 71414ae

Browse files
committed
feat(69389): integrate the condition for releasing from feature branches
1 parent 16575f6 commit 71414ae

4 files changed

Lines changed: 84 additions & 18 deletions

File tree

.github/workflows/ci-cd-java.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
jarArtifactPath:
1818
required: false
1919
type: string
20+
performRelease:
21+
required: false
22+
type: boolean
23+
default: false
2024

2125
env:
2226
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
@@ -71,12 +75,24 @@ jobs:
7175
push: 'false'
7276
tags: 'hsldevcom/${{ env.IMAGE_NAME }}:${{ github.sha }}'
7377

78+
- name: Check if perform release
79+
id: perform_release
80+
run: |
81+
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/develop" || "${GITHUB_REF}" == "refs/heads/aks-dev"]]; then
82+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
83+
elif [[ "${{ inputs.performRelease }}" == "true" ]]; then
84+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
85+
else
86+
echo "PERFORM_RELEASE=false" >> $GITHUB_ENV
87+
fi
88+
echo "Perform release condition: PERFORM_RELEASE"
89+
7490
- name: Setup Docker Buildx
75-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
91+
if: env.PERFORM_RELEASE == 'true'
7692
uses: docker/setup-buildx-action@v3
7793

7894
- name: Extract Docker metadata
79-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
95+
if: env.PERFORM_RELEASE == 'true'
8096
id: meta
8197
uses: docker/metadata-action@v5
8298
with:
@@ -90,18 +106,18 @@ jobs:
90106
org.opencontainers.image.vendor=hsldevcom
91107
92108
- name: Login to Github Container Registry
93-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
109+
if: env.PERFORM_RELEASE == 'true'
94110
uses: docker/login-action@v3
95111
with:
96112
username: ${{ secrets.DOCKER_USERNAME }}
97113
password: ${{ secrets.DOCKER_PASSWORD }}
98114

99115
- name: Build & Push Docker image
100-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
116+
if: env.PERFORM_RELEASE == 'true'
101117
uses: docker/build-push-action@v6
102118
with:
103119
context: .
104-
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
120+
push: ${{ env.PERFORM_RELEASE }}
105121
tags: ${{ steps.meta.outputs.tags }}
106122
labels: ${{ steps.meta.outputs.labels }}
107123

.github/workflows/ci-cd-kotlin.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,10 @@ on:
1717
jarArtifactPath:
1818
required: false
1919
type: string
20+
performRelease:
21+
required: false
22+
type: boolean
23+
default: false
2024

2125
env:
2226
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
@@ -67,12 +71,24 @@ jobs:
6771
push: 'false'
6872
tags: 'hsldevcom/${{ env.IMAGE_NAME }}:${{ github.sha }}'
6973

74+
- name: Check if perform release
75+
id: perform_release
76+
run: |
77+
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/develop" || "${GITHUB_REF}" == "refs/heads/aks-dev"]]; then
78+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
79+
elif [[ "${{ inputs.performRelease }}" == "true" ]]; then
80+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
81+
else
82+
echo "PERFORM_RELEASE=false" >> $GITHUB_ENV
83+
fi
84+
echo "Perform release condition: PERFORM_RELEASE"
85+
7086
- name: Setup Docker Buildx
71-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
87+
if: env.PERFORM_RELEASE == 'true'
7288
uses: docker/setup-buildx-action@v3
7389

7490
- name: Extract Docker metadata
75-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
91+
if: env.PERFORM_RELEASE == 'true'
7692
id: meta
7793
uses: docker/metadata-action@v5
7894
with:
@@ -86,17 +102,17 @@ jobs:
86102
org.opencontainers.image.vendor=hsldevcom
87103
88104
- name: Login to Docker Hub
89-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
105+
if: env.PERFORM_RELEASE == 'true'
90106
uses: docker/login-action@v3
91107
with:
92108
username: ${{ secrets.DOCKER_USERNAME }}
93109
password: ${{ secrets.DOCKER_PASSWORD }}
94110

95111
- name: Build & Push Docker image
96-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
112+
if: env.PERFORM_RELEASE == 'true'
97113
uses: docker/build-push-action@v6
98114
with:
99115
context: .
100-
push: ${{ github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop' }}
116+
push: ${{ env.PERFORM_RELEASE }}
101117
tags: ${{ steps.meta.outputs.tags }}
102118
labels: ${{ steps.meta.outputs.labels }}

.github/workflows/ci-cd-python.yml

Lines changed: 21 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,10 @@ on:
1212
required: false
1313
type: boolean
1414
default: false
15+
performRelease:
16+
required: false
17+
type: boolean
18+
default: false
1519

1620
env:
1721
IMAGE_NAME_MIXED_CASE: "${{ github.repository }}"
@@ -46,8 +50,20 @@ jobs:
4650
if: ${{ inputs.runTests }}
4751
run: pytest --junitxml=test-results.xml
4852

53+
- name: Check if perform release
54+
id: perform_release
55+
run: |
56+
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/develop" || "${GITHUB_REF}" == "refs/heads/aks-dev"]]; then
57+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
58+
elif [[ "${{ inputs.performRelease }}" == "true" ]]; then
59+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
60+
else
61+
echo "PERFORM_RELEASE=false" >> $GITHUB_ENV
62+
fi
63+
echo "Perform release condition: PERFORM_RELEASE"
64+
4965
- name: Build package
50-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
66+
if: env.PERFORM_RELEASE == 'true'
5167
run: python -m build
5268

5369
- name: Lowercase Docker Image Name
@@ -62,11 +78,11 @@ jobs:
6278
tags: 'hsldevcom/${{ env.IMAGE_NAME }}:${{ github.sha }}'
6379

6480
- name: Setup Docker Buildx
65-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
81+
if: env.PERFORM_RELEASE == 'true'
6682
uses: docker/setup-buildx-action@v3
6783

6884
- name: Extract Docker metadata
69-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
85+
if: env.PERFORM_RELEASE == 'true'
7086
id: meta
7187
uses: docker/metadata-action@v5
7288
with:
@@ -80,14 +96,14 @@ jobs:
8096
org.opencontainers.image.vendor=hsldevcom
8197
8298
- name: Login to Docker Hub
83-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
99+
if: env.PERFORM_RELEASE == 'true'
84100
uses: docker/login-action@v3
85101
with:
86102
username: ${{ secrets.DOCKER_USERNAME }}
87103
password: ${{ secrets.DOCKER_PASSWORD }}
88104

89105
- name: Build & Push Docker image
90-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
106+
if: env.PERFORM_RELEASE == 'true'
91107
uses: docker/build-push-action@v6
92108
with:
93109
context: .

.github/workflows/ci-cd-typescript.yml

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,10 @@ on:
1515
required: false
1616
type: boolean
1717
default: false
18+
performRelease:
19+
required: false
20+
type: boolean
21+
default: false
1822

1923

2024
env:
@@ -58,6 +62,20 @@ jobs:
5862
with:
5963
token: ${{ secrets.CODECOV_TOKEN }}
6064

65+
- name: Check if perform release
66+
id: perform_release
67+
run: |
68+
if [[ "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == "refs/heads/develop" || "${GITHUB_REF}" == "refs/heads/aks-dev"]]; then
69+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
70+
elif [[ "${GITHUB_EVENT_NAME}" == "push" && ( "${GITHUB_REF}" == "refs/heads/main" || "${GITHUB_REF}" == refs/tags/* ) ]]; then
71+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
72+
elif [[ "${{ inputs.performRelease }}" == "true" ]]; then
73+
echo "PERFORM_RELEASE=true" >> $GITHUB_ENV
74+
else
75+
echo "PERFORM_RELEASE=false" >> $GITHUB_ENV
76+
fi
77+
echo "Perform release condition: PERFORM_RELEASE"
78+
6179
- name: Lowercase Docker Image Name
6280
run: |
6381
echo "IMAGE_NAME=${IMAGE_NAME_MIXED_CASE,,}" >> "${GITHUB_ENV}"
@@ -75,7 +93,7 @@ jobs:
7593
type=sha,format=long
7694
7795
- name: Setup Docker Buildx
78-
if: github.ref == 'refs/heads/main' || github.ref == 'refs/heads/develop'
96+
if: env.PERFORM_RELEASE == 'true'
7997
uses: docker/setup-buildx-action@v3
8098

8199
- name: Build and export to Docker
@@ -91,14 +109,14 @@ jobs:
91109
docker run --rm "${{ env.IMAGE_NAME }}:${{ env.TEST_STAGE }}"
92110
93111
- name: Login to Docker Hub
94-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/'))
112+
if: env.PERFORM_RELEASE == 'true'
95113
uses: docker/login-action@v3
96114
with:
97115
username: ${{ secrets.DOCKER_USERNAME }}
98116
password: ${{ secrets.DOCKER_PASSWORD }}
99117

100118
- name: Build and push
101-
if: github.event_name == 'push' && (github.ref == 'refs/heads/main' || contains(github.ref, 'refs/tags/'))
119+
if: env.PERFORM_RELEASE == 'true'
102120
uses: docker/build-push-action@v6
103121
with:
104122
context: .

0 commit comments

Comments
 (0)