Skip to content

Commit e853201

Browse files
committed
feat: add preCommit logic to change docker image version in auto-deploy.gitlab-ci.yml upon new releases
install yq Signed-off-by: Siddharth Tiwari <[email protected]>
1 parent c89e89d commit e853201

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

.github/workflows/ci.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,11 +51,19 @@ jobs:
5151
brew tap helm/tap
5252
brew install chart-releaser
5353
54+
- name: Install yq
55+
run: |
56+
sudo curl -sLo /usr/local/bin/yq \
57+
https://github.com/mikefarah/yq/releases/download/v4.3.2/yq_linux_amd64 && \
58+
sudo chmod +x /usr/local/bin/yq
59+
yq -V
60+
5461
- name: Conventional Changelog Action
5562
id: changelog
5663
uses: TriPSs/conventional-changelog-action@v3
5764
with:
5865
github-token: ${{ secrets.github_token }}
66+
pre-commit: preCommit.js
5967
version-file: ./chart/lambda/Chart.yaml
6068
version-path: version
6169
release-count: 0

preCommit.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/usr/bin/env node
2+
const { execSync } = require( "child_process" );
3+
exports.preCommit = ( props ) =>
4+
{
5+
const { CI_REPOSITORY_OWNER_SLUG, CI_REPOSITORY_NAME_SLUG } = process.env
6+
const tag = props.tag
7+
imageName = `ghcr.io/${ CI_REPOSITORY_OWNER_SLUG }/${ CI_REPOSITORY_NAME_SLUG }:${ tag }`
8+
ciFileName = 'auto-deploy.gitlab-ci.yml'
9+
command = `yq eval -i '.".auto-deploy".image = "${ imageName }" ' ${ ciFileName }`
10+
execSync( command )
11+
12+
}

0 commit comments

Comments
 (0)