Skip to content

Commit b755d79

Browse files
author
Dario
committed
ci: only push when there are changes
1 parent a7ee310 commit b755d79

1 file changed

Lines changed: 16 additions & 5 deletions

File tree

.github/workflows/plconfig.yaml

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -170,13 +170,24 @@ jobs:
170170
yq '{ "dependencies": .deployment.kubernetes.env.${{ matrix.env }}.dependencies } * {"apiVersion": "v2", "name": "${{ fromJSON(steps.json.outputs.result).name }}", "description": "${{ fromJSON(steps.json.outputs.result).description }} (${{ matrix.env }})", "version": "0.0.0"}' ${{ inputs.configurationFilepath }} > ${{ steps.vars.outputs.namespace-path }}/${{ matrix.env }}/${{ fromJSON(steps.json.outputs.result).name }}/Chart.yaml
171171
# Commit & Push to GitOps repo
172172
- name: Commit deployment files for ${{ matrix.env }}
173+
id: commit
173174
run: |
174175
cd remote
175-
git config --global user.email "${{ inputs.botEmail }}"
176-
git config --global user.name "${{ inputs.botName }}"
177-
git add .
178-
git commit --allow-empty -m "chore(${{ fromJSON(steps.json.outputs.result).name }}): set parcelLab ${{ matrix.env }} config values"
179-
- name: Push changes to main in ${{ inputs.deploymentRepoURL }} git repository for ${{ matrix.env }}
176+
if [[ $(git status --porcelain --untracked-files=no | wc -l) -gt 0 ]]; then
177+
# Untracked changes
178+
git config --global user.email "${{ inputs.botEmail }}"
179+
git config --global user.name "${{ inputs.botName }}"
180+
git add .
181+
git commit --allow-empty -m "chore(${{ fromJSON(steps.json.outputs.result).name }}): set parcelLab ${{ matrix.env }} config values"
182+
# shellcheck disable=SC2086
183+
echo "has-changes=true" >> $GITHUB_OUTPUT
184+
else
185+
# No changes, ignore
186+
# shellcheck disable=SC2086
187+
echo "has-changes=false" >> $GITHUB_OUTPUT
188+
fi
189+
- if: steps.commit.outputs.has-changes == 'true'
190+
name: Push changes to main in ${{ inputs.deploymentRepoURL }} git repository for ${{ matrix.env }}
180191
uses: ad-m/github-push-action@0fafdd62b84042d49ec0cb92d9cac7f7ce4ec79e
181192
with:
182193
repository: ${{ inputs.deploymentRepoURL }}

0 commit comments

Comments
 (0)