Skip to content

Commit ed2c7fe

Browse files
authored
Fix the version in package.json file while GHA call image build (#30)
1 parent 3a28f9a commit ed2c7fe

File tree

2 files changed

+17
-4
lines changed

2 files changed

+17
-4
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: "filplus-provider-benchmark"
@@ -20,6 +23,8 @@ jobs:
2023
steps:
2124
- name: Checkout code
2225
uses: actions/checkout@v4
26+
with:
27+
ref: ${{ inputs.commit_sha }}
2328

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

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

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,9 @@ on:
1010
workflow_dispatch:
1111
inputs:
1212
version:
13-
description: 'Enter the version number'
13+
description: "Enter the version number"
1414
required: true
15-
default: 'latest'
15+
default: "latest"
1616

1717
permissions:
1818
contents: write
@@ -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,11 +65,14 @@ 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:
6772
runs-on: ubuntu-latest
68-
needs: build-and-publish
73+
needs:
74+
- bump-version
75+
- build-and-publish
6976
if: |
7077
${{ github.ref_name == 'main' && inputs.version != '' }} &&
7178
always() &&
@@ -74,10 +81,11 @@ jobs:
7481
steps:
7582
- name: Checkout code
7683
uses: actions/checkout@v4
84+
with:
85+
ref: ${{ needs.bump-version.outputs.commit_sha }}
7786

7887
- name: Create and push tag
7988
run: |
8089
TAG_NAME="v${{ inputs.version }}"
8190
git tag $TAG_NAME
8291
git push origin $TAG_NAME
83-

0 commit comments

Comments
 (0)