Last active
August 7, 2023 23:42
-
-
Save alexandrebrg/f19c526df9c0331a3101b8a27fde9dce to your computer and use it in GitHub Desktop.
Revisions
-
alexandrebrg revised this gist
Aug 7, 2023 . 1 changed file with 1 addition and 1 deletion.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -18,7 +18,7 @@ jobs: pull-requests: read steps: - uses: actions/checkout@v3 name: Checkout Repository with: ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.GITHUB_TOKEN }} -
alexandrebrg created this gist
Aug 7, 2023 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,5 @@ # Determine files changed in Pull Request # Determine directories changed in Pull Request # Determine which Helm Charts have been changed in Pull Request This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,44 @@ # Github Workflow name: 'Read diff' on: pull_request_target: branches: - main paths: - 'some_folder/**/*.yaml' # For security purposes, it preferred to lower permissions to the minimal, always, and then add job by job permissions: {} jobs: read-diff: runs-on: ubuntu-latest permissions: pull-requests: read steps: - uses: actions/checkout@v3 name: Checkout Conduktor Charts with: ref: ${{ github.event.pull_request.head.ref }} token: ${{ secrets.GITHUB_TOKEN }} - name: Execute read-diff env: # Needed for Github CLI to work GH_TOKEN: ${{ github.token }} TEMP_FILE: "${{runner.temp}}/pr-${{github.event.number}}.diff" run: | export PR_ID=$(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") # Gives a GIT Diff file # check: https://git-scm.com/docs/git-diff#_combined_diff_format gh pr diff ${PR_ID} > $TEMP_FILE # We filter only names of files files_changed="$(sed -nr 's/[\-\+]{3} [ab]\/(.*)/\1/p' $TEMP_FILE | sort | uniq)" # If you want to get all files changed, you can use variable $files_changed # but if you want to get upper directories, use customize and use $some_specific_dir_changed # Adding || true to avoid "Process exited with code 1" errors some_specific_dir_changed="$(echo "$files_changed" | xargs dirname | grep -o "templates/[^/]*" | sort | uniq || true)" for dir in ${some_specific_dir_changed}; do echo "Detected $dir changed" done