-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
⬆️ Bump yq version #41
Changes from 4 commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -139,8 +139,17 @@ runs: | |
cache-from: type=gha | ||
cache-to: type=gha,mode=max | ||
|
||
- name: Checkout GitOps Repository | ||
if: inputs.gitopsenabled == 'true' | ||
uses: actions/checkout@v3 | ||
with: | ||
repository: ${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }} | ||
token: ${{ inputs.gitopstoken }} | ||
path: .github/${{ inputs.gitopsrepository }} | ||
|
||
- name: Update Docker Image in Repository | ||
if: inputs.gitopsenabled == 'true' | ||
working-directory: .github/${{ inputs.gitopsrepository }} | ||
shell: bash | ||
run: | | ||
commit_changes () { | ||
|
@@ -152,53 +161,50 @@ runs: | |
fi | ||
} | ||
|
||
# download and install yq | ||
sudo wget -O /usr/local/bin/yq https://github.com/mikefarah/yq/releases/download/3.4.1/yq_linux_amd64 | ||
sudo chmod +x /usr/local/bin/yq | ||
|
||
# configure git user | ||
git config --global user.email "${{ inputs.gitopsemail }}" && git config --global user.name "${{ inputs.gitopsuser }}" | ||
|
||
git clone https://${{ inputs.gitopsuser }}:${{ inputs.gitopstoken }}@github.com/${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }}.git .github/${{ inputs.gitopsrepository }} | ||
cd .github/${{ inputs.gitopsrepository }} | ||
echo "Repository ${{ inputs.gitopsorganization }}/${{ inputs.gitopsrepository }} was cloned successfully " | ||
Comment on lines
-161
to
-163
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. use explicit checkout action |
||
|
||
if [[ ( $GITHUB_REF == refs/heads/master || $GITHUB_REF == refs/heads/main ) && -n "${{ inputs.gitopsstage }}" ]]; then | ||
echo "Run update for STAGE" | ||
while IFS= read -r line; do | ||
array=($line) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. split input by blank |
||
echo "Check if path $line exists and get old current version" | ||
yq r -e $line | ||
yq -e .${array[1]} ${array[0]} | ||
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}" | ||
yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }} | ||
yq -i .${array[1]}=\"${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}\" ${array[0]} | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. migrated the calls from version 3 to 4 |
||
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 | ||
array=($line) | ||
echo "Check if path $line exists and get old current version" | ||
yq r -e $line | ||
yq -e .${array[1]} ${array[0]} | ||
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}" | ||
yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }} | ||
yq -i .${array[1]}=\"${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}\" ${array[0]} | ||
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 | ||
array=($line) | ||
echo "Check if path $line exists and get old current version" | ||
yq r -e $line | ||
yq -e .${array[1]} ${array[0]} | ||
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}" | ||
yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }} | ||
yq -i .${array[1]}=\"${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}\" ${array[0]} | ||
done <<< "${{ inputs.gitopsprod }}" | ||
commit_changes | ||
|
||
elif [[ -n "${{ inputs.gitopsdev }}" ]]; then | ||
echo "Simulate update for DEV" | ||
while IFS= read -r line; do | ||
array=($line) | ||
echo "Check if path $line exists and get old current version" | ||
yq r -e $line | ||
yq -e .${array[1]} ${array[0]} | ||
echo "Run update $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}" | ||
yq w -i $line ${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }} | ||
yq -i .${array[1]}=\"${{ inputs.dockerregistry }}/${{ inputs.dockerimage }}:${{ steps.preparation.outputs.tag }}\" ${array[0]} | ||
done <<< "${{ inputs.gitopsdev }}" | ||
commit_changes | ||
fi |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
yq is already part of the github action with ubuntu 20: https://github.com/actions/virtual-environments/blob/main/images/linux/Ubuntu2004-Readme.md#tools