Skip to content

Commit 15f1192

Browse files
committed
feat(github): changed images
fix(github): typo fix(github): array fix(github): changed fix(github): typo fix(github): shell fix(github): typo fix(github): packages fix(github): order fix(github): typo fix(github): typo fix(github): typo fix(github): debug fix(github): typo fix(github): typo fix(github): jenkins typo fix(github): array fix(github): typo fix(github): typos fix(github): typos
1 parent b6cd996 commit 15f1192

File tree

2 files changed

+68
-18
lines changed

2 files changed

+68
-18
lines changed

.github/workflows/reusable-jenkins-trigger.yaml

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ jobs:
5656
JENKINS_DEPLOY_USER: ${{ secrets.USER }}
5757
JENKINS_DEPLOY_TOKEN: ${{ secrets.TOKEN }}
5858
JOB_NAME: ${{ inputs.job_name }}
59-
IMAGE_TAG: ${{ inputs.image_tag }}
60-
GIT_BRANCH_NAME: ${{ inputs.git_branch_name }}
59+
IMAGE_TAG: ${{ inputs.image_tag || 'latest' }}
60+
GIT_BRANCH_NAME: ${{ inputs.git_branch_name || github.ref_name }}
6161
GIT_COMMIT: ${{ inputs.git_commit }}
6262
GIT_COMMIT_MSG: ${{ inputs.git_commit_msg }}
6363
GIT_COMMIT_AUTHOR: ${{ inputs.git_commit_author }}
@@ -101,19 +101,21 @@ jobs:
101101
steps:
102102
- uses: actions/checkout@v4
103103

104-
- name: Changed files
105-
id: changed_files
104+
- id: changed_files
106105
uses: tj-actions/changed-files@v46.0.5
107106

108107
- name: Check if any services need deploy
109108
id: changed_packages
110109
env:
111110
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
112-
PATH: ${{ inputs.path }}
111+
SEARCH_PATH: ${{ inputs.path }}
113112
run: |
114-
echo "packages=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep "${PATH}/" | awk -F'/' '{print $2}' | uniq)" >> "$GITHUB_OUTPUT"
113+
echo "CHANGED_FILES: $CHANGED_FILES"
115114
116-
echo $packages
115+
packages=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep "^${SEARCH_PATH}/" | awk -F '/' '{print $2}' | uniq | tr '\n' ' ')
116+
echo "packages=${packages}" >> "$GITHUB_OUTPUT"
117+
118+
echo "Found packages: $packages"
117119
118120
- name: Trigger jenkins all
119121
if: ${{ contains(steps.changed_packages.outputs.packages, 'core') }}

.github/workflows/reusable-php-docker-publish.yaml

Lines changed: 59 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -3,22 +3,30 @@ name: Reusable PHP docker publish
33
on:
44
workflow_call:
55

6+
env:
7+
SEARCH_PATH: packages
8+
69
jobs:
710
run:
8-
name: Publish PHP docker images
911
runs-on: ubuntu-latest
1012

1113
steps:
12-
- name: Login to GitHub Container Registry
13-
uses: docker/login-action@v3
14-
with:
15-
registry: ghcr.io
16-
username: ${{ github.repository_owner }}
17-
password: ${{ secrets.GITHUB_TOKEN }}
18-
1914
- uses: actions/checkout@v4
20-
with:
21-
ref: ${{ github.base_ref }}
15+
16+
- id: changed_files
17+
uses: tj-actions/changed-files@v46.0.5
18+
19+
- name: Check if any services need deploy
20+
id: changed_packages
21+
env:
22+
CHANGED_FILES: ${{ steps.changed_files.outputs.all_changed_files }}
23+
run: |
24+
echo "CHANGED_FILES: $CHANGED_FILES"
25+
26+
packages=$(echo "$CHANGED_FILES" | tr ' ' '\n' | grep "^${SEARCH_PATH}/" | awk -F '/' '{print $2}' | uniq | tr '\n' ' ')
27+
echo "packages=${packages}" >> "$GITHUB_OUTPUT"
28+
29+
echo "Found packages: $packages"
2230
2331
- name: Set tags
2432
id: tags
@@ -37,6 +45,12 @@ jobs:
3745
echo "tagPrefix=$TAG_PREFIX" >> "$GITHUB_OUTPUT"
3846
echo "tagSuffix=$TAG_SUFFIX" >> "$GITHUB_OUTPUT"
3947
48+
- uses: docker/login-action@v3
49+
with:
50+
registry: ghcr.io
51+
username: ${{ github.repository_owner }}
52+
password: ${{ secrets.GITHUB_TOKEN }}
53+
4054
- uses: docker/setup-buildx-action@v3
4155

4256
- name: Build and push core image
@@ -50,7 +64,8 @@ jobs:
5064
cache-from: type=gha,scope=core
5165
cache-to: type=gha,mode=max,scope=core
5266

53-
- name: Build and Push Docker images
67+
- name: Build and push all docker images
68+
if: contains(steps.changed_packages.outputs.packages, 'core')
5469
env:
5570
REPOSITORY_OWNER: ${{ github.repository_owner }}
5671
SOURCE_PATH: packages
@@ -73,6 +88,7 @@ jobs:
7388
IMAGE_NAME_LATEST=ghcr.io/$REPOSITORY_OWNER/$PACKAGE_NAME:${{ steps.tags.outputs.tagSuffix }}
7489
7590
echo "📦 ${IMAGE_NAME} → ${IMAGE_NAME_LATEST}"
91+
7692
docker buildx build . \
7793
--file "${package}" \
7894
--tag "${IMAGE_NAME}" \
@@ -84,3 +100,35 @@ jobs:
84100
85101
echo "✅ pushed ${IMAGE_NAME} + ${IMAGE_NAME_LATEST}"
86102
done
103+
104+
- name: Build and push changed docker images
105+
if: ${{ !contains(steps.changed_packages.outputs.packages, 'core') }}
106+
env:
107+
REPOSITORY_OWNER: ${{ github.repository_owner }}
108+
CHANGED_FILES: ${{ steps.changed_packages.outputs.packages }}
109+
run: |
110+
echo "Trying to build packages: $CHANGED_FILES"
111+
112+
for package in $CHANGED_FILES; do
113+
114+
if [ "$package" = "core" ]; then
115+
echo "⏭️ Skipping build for core package"
116+
continue
117+
fi
118+
119+
IMAGE_NAME=ghcr.io/$REPOSITORY_OWNER/$package:${{ steps.tags.outputs.tagPrefix }}$(git rev-parse --short HEAD)-$(date +%s)
120+
IMAGE_NAME_LATEST=ghcr.io/$REPOSITORY_OWNER/$package:${{ steps.tags.outputs.tagSuffix }}
121+
122+
echo "📦 ${IMAGE_NAME} → ${IMAGE_NAME_LATEST}"
123+
124+
docker buildx build . \
125+
--file "$SEARCH_PATH/${package}/Dockerfile" \
126+
--tag "${IMAGE_NAME}" \
127+
--tag "${IMAGE_NAME_LATEST}" \
128+
--cache-from type=gha,scope="${package}" \
129+
--cache-to type=gha,scope="${package}" \
130+
--push \
131+
--progress plain \
132+
133+
echo "✅ pushed ${IMAGE_NAME} + ${IMAGE_NAME_LATEST}"
134+
done

0 commit comments

Comments
 (0)