Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,15 @@ runs:
- name: Update Docker Image in Repository
shell: bash
run: |
commit_changes () {
if [[ ${{ steps.preparation.outputs.push }} == "true" ]]; then
git add . && git commit -m "Release ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
# In case there was another push in the meantime, we pull it again
git pull --rebase https://${{ inputs.gitopsuser }}:${{ inputs.gitopstoken }}@github.com/${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }}.git
git push https://${{ inputs.gitopsuser }}:${{ inputs.gitopstoken }}@github.com/${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }}.git
fi
}

if [[ ${{ inputs.gitopsenabled }} == "true" ]]; then
git config --global user.email "${{ inputs.gitopsemail }}" && git config --global user.name "${{ inputs.gitopsuser }}"

Expand All @@ -140,6 +149,8 @@ runs:
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
../gitops/yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}
done <<< "${{ inputs.gitopsstage }}"
commit_changes

elif [[ $GITHUB_REF == refs/heads/dev && -n "${{ inputs.gitopsdev }}" ]]; then
echo "Run update for DEV"
while IFS= read -r line; do
Expand All @@ -148,6 +159,8 @@ runs:
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
../gitops/yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}
done <<< "${{ inputs.gitopsdev }}"
commit_changes

elif [[ $GITHUB_REF == refs/tags/* && -n "${{ inputs.gitopsprod }}" ]]; then
echo "Run update for PROD"
while IFS= read -r line; do
Expand All @@ -156,6 +169,8 @@ runs:
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
../gitops/yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}
done <<< "${{ inputs.gitopsprod }}"
commit_changes

elif [[ -n "${{ inputs.gitopsdev }}" ]]; then
echo "Simulate update for DEV"
while IFS= read -r line; do
Expand All @@ -164,11 +179,6 @@ runs:
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
../gitops/yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}
done <<< "${{ inputs.gitopsdev }}"
fi

if [[ ${{ steps.preparation.outputs.push }} == "true" ]]; then
git add . && git commit -m "Release ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}"
git pull --rebase https://${{ inputs.gitopsuser }}:${{ inputs.gitopstoken }}@github.com/${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }}.git # in case there was another push in the meantime
git push https://${{ inputs.gitopsuser }}:${{ inputs.gitopstoken }}@github.com/${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }}.git
commit_changes
fi
fi