Skip to content

UPdate main

UPdate main #84

Workflow file for this run

name: Update Values File
on:
push:
branches:
- main
- dev
tags:
- "v*" # Triggered by tags starting with 'v'
jobs:
update-values:
runs-on: ubuntu-latest
steps:
# - name: Setup Git
# run: apt-get update -y && apt-get install git -y
- name: Checkout Target Repository
uses: actions/checkout@v4
with:
repository: 5h4k4r/pilgrimage-gitops-shakar # Replace with the actual target repository
token: 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 # insert the token
- name: Determine Environment
id: env
run: |
if [[ $GITHUB_REF == refs/tags/* ]]; then
environment=production
elif [[ $GITHUB_REF == refs/heads/main ]]; then
environment=staging
else
environment=dev
fi
echo "::set-output name=environment::${environment}"
- name: Determine Component Name
id: component
run: |
component=$(basename $PWD)
echo "::set-output name=component::${component}"
- name: Update Values File
run: |
environment=${{ steps.env.outputs.environment }}
component=${{ steps.component.outputs.component }}
if [ $environment == "production" ]; then
target_file="overlays/production/values.yaml"
elif [ $environment == "staging" ]; then
target_file="overlays/staging/values.yaml"
else
target_file="overlays/development/values.yaml"
fi
# Update the values.yaml file with the new image tag
# You'll need to customize the logic to update your specific file
# Example command to update image tag:
# Update the image.tag field in the values.yaml file
image_tag="$GITHUB_REF"
echo "Helo world" >> "oauth2-proxy/$target_file"
env:
GITHUB_REF: ${{ github.ref }}
- name: print Values
run: |
environment=${{ steps.env.outputs.environment }}
component=${{ steps.component.outputs.component }}
branch_name="update-$component-$environment"
echo "git checkout -b $branch_name"
echo "Update $component/$target_file for $environment"
- name: Import GPG key
id: import-gpg
uses: crazy-max/ghaction-import-gpg@v4
with:
gpg_private_key: ${{ secrets.PGP_PRIVATE_KEY }}
git_user_signingkey: true
git_commit_gpgsign: true
- name: GPG user IDs
run: |
echo "fingerprint: ${{ steps.import-gpg.outputs.fingerprint }}"
echo "keyid: ${{ steps.import-gpg.outputs.keyid }}"
echo "name: ${{ steps.import-gpg.outputs.name }}"
echo "email: ${{ steps.import-gpg.outputs.email }}"
# - name: Commit Changes
# run: |
# environment=${{ steps.env.outputs.environment }}
# component=${{ steps.component.outputs.component }}
# branch_name="update-$component-$environment"
# target_file=${{ steps.update-values.outputs.target_file }}
# echo "git checkout -b $branch_name"
# echo "Update $component/$target_file for $environment"
# git config receive.advertisePushOptions true
# git config --global user.email "${{ steps.import-gpg.outputs.email }}"
# git config --global user.name "${{ steps.import-gpg.outputs.name }}"
# git config --global user.signingkey "${{ steps.import-gpg.outputs.keyid }}"
# git config --global commit.gpgsign true
# # Do not create a new branch if the branch already exists
# if [[ $(git ls-remote origin $branch_name) ]]; then
# git checkout $branch_name
# else
# git checkout -b $branch_name
# fi
# git add .
# git commit -S -m "Update oauth2-proxy/$target_file for $environment"
# git push origin $branch_name
# env:
# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- uses: stefanzweifel/git-auto-commit-action@v5
with:
commit_message: message
# branch: update-${{ steps.component.outputs.component }}-${{ steps.env.outputs.environment }}
commit_user_name: DIT Bot
commit_user_email: [email protected]
commit_author: DIT Bot [email protected]