Skip to content

Commit 38128cc

Browse files
authored
Fix the version in package.json file while GHA call image build (#10)
1 parent bbf78b9 commit 38128cc

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

.github/workflows/build-docker-image.yml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@ on:
77
version:
88
required: false
99
type: string
10+
commit_sha:
11+
required: false
12+
type: string
1013

1114
env:
1215
ECR_REPOSITORY: "provider-sample-url-finder"
@@ -19,6 +22,8 @@ jobs:
1922
steps:
2023
- name: Checkout code
2124
uses: actions/checkout@v4
25+
with:
26+
ref: ${{ inputs.commit_sha }}
2227

2328
- name: Set up Docker Buildx
2429
uses: docker/setup-buildx-action@v3

.github/workflows/publish-new-build.yml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ jobs:
2626
runs-on: ubuntu-latest
2727
needs: code-check
2828
if: ${{ github.ref_name == 'main' && inputs.version != '' }}
29+
outputs:
30+
commit_sha: ${{ steps.commit-version.outputs.commit_sha }}
2931

3032
steps:
3133
- name: Checkout code
@@ -46,9 +48,11 @@ jobs:
4648
git config user.email "${GITHUB_ACTOR}@users.noreply.github.com"
4749
4850
- name: Commit version change
51+
id: commit-version
4952
run: |
5053
git commit -am "Update version to ${{ inputs.version }}"
5154
git push origin main
55+
echo "commit_sha=$(git rev-parse HEAD)" >> $GITHUB_OUTPUT
5256
5357
build-and-publish:
5458
needs:
@@ -61,6 +65,7 @@ jobs:
6165
uses: ./.github/workflows/build-docker-image.yml
6266
with:
6367
version: ${{ inputs.version }}
68+
commit_sha: ${{ github.ref_name == 'main' && inputs.version != '' && needs.bump-version.outputs.commit_sha || '' }}
6469
secrets: inherit
6570

6671
git-tag:
@@ -74,6 +79,8 @@ jobs:
7479
steps:
7580
- name: Checkout code
7681
uses: actions/checkout@v4
82+
with:
83+
ref: ${{ needs.bump-version.outputs.commit_sha }}
7784

7885
- name: Create and push tag
7986
run: |

0 commit comments

Comments
 (0)