Skip to content

Commit

Permalink
Revert "feat(ci): adjust scripts to run safely for external PRs (#1269)"
Browse files Browse the repository at this point in the history
This reverts commit 9f298ce.
  • Loading branch information
marvinWolff authored Jan 9, 2025
1 parent 20d0ad8 commit 857dad7
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 56 deletions.
37 changes: 11 additions & 26 deletions .github/scripts/create-values-diff.sh
Original file line number Diff line number Diff line change
Expand Up @@ -6,34 +6,21 @@
set -eu
set -o pipefail

parsed="$(getopt --options '' --longoptions "body:,dry-run" --name "$0" -- "$@")"

eval set -- "$parsed"
unset parsed

dryRun=false

while [[ "$#" -gt 0 ]]; do
case "$1" in
issue=${1?You need to provide the issue ID}
chart=${2?You need to provide the chart name}
if [[ -v 3 ]]; then
case "$3" in
--dry-run)
dryRun=true
;;
--body)
shift
body="${1}"
if [[ ! -f "$body" ]]; then
echo "input file '$body' does not exist" >&2
exit 3
fi
;;
--) # positional arguments
shift
issue=${1?You need to provide the issue ID}
chart=${2?You need to provide the chart name}
*)
echo "Option '$3' not supported" >&2
exit 1
;;
esac
shift
done
else
dryRun=false
fi

if yq -e '.type == "library"' "$chart/Chart.yaml" >/dev/null; then
echo "Skipping library chart '$chart'" >&2
Expand Down Expand Up @@ -144,9 +131,7 @@ function updateComment() {
-d @-
}

if [[ ! -v body ]]; then
body=$(generateComment "$chart")
fi
body=$(generateComment "$chart")

if [[ "$dryRun" == false ]]; then
# cannot use `gh pr/issue view --json comments` as the returned id is incorrect
Expand Down
4 changes: 1 addition & 3 deletions .github/workflows/check-licenses.yaml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
name: Check used licenses

on:
pull_request_target:
pull_request:
types:
- opened
- edited
Expand Down Expand Up @@ -35,8 +35,6 @@ jobs:
needs: getChangedChart
steps:
- uses: actions/checkout@692973e3d937129bcbf40652eb9f2f61becf3332 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: pip install yq
- env:
chart: ${{ needs.getChangedChart.outputs.chart }}
Expand Down
32 changes: 5 additions & 27 deletions .github/workflows/pr-comment-diff.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ concurrency:
cancel-in-progress: true

on:
pull_request_target:
pull_request:
paths:
- charts/**
branches-ignore:
Expand All @@ -15,38 +15,16 @@ jobs:
uses: ./.github/workflows/get-changed-chart.yaml
with:
pr_number: ${{ github.event.pull_request.number }}
generateDiffCommentBody:
postDiffComment:
runs-on: ubuntu-latest
needs: getChangedChart
permissions:
contents: read
pull-requests: read
env:
CT_TARGET_BRANCH: ${{ github.event.pull_request.base.ref || github.event.repository.default_branch }}
GITHUB_TOKEN: ${{ secrets.ACTIONS_BOT_TOKEN }}
steps:
- uses: actions/checkout@11bd71901bbe5b1630ceea73d27597364c9af683 # v4
with:
ref: ${{ github.event.pull_request.head.sha }}
- run: pip install yq
- name: Install sponge
run: sudo apt-get -yq install moreutils
- run: ./.github/scripts/prepare-values.sh "pr/charts/${{ needs.getChangedChart.outputs.chart }}"
- run: ./.github/scripts/create-values-diff.sh ${{ github.event.number }} "pr/charts/${{ needs.getChangedChart.outputs.chart }}" --dry-run > comment_body.md
- uses: actions/upload-artifact@v4
with:
name: comment_body
path: comment_body.md
if-no-files-found: error
retention-days: 1
postDiffComment:
runs-on: ubuntu-latest
needs:
- getChangedChart
- generateDiffCommentBody
env:
GITHUB_TOKEN: ${{ secrets.ACTIONS_BOT_TOKEN }}
steps:
- uses: actions/download-artifact@v4
with:
name: comment_body
- run: ./.github/scripts/create-values-diff.sh ${{ github.event.number }} "charts/${{ needs.getChangedChart.outputs.chart }}" --body comment_body.md
- run: ./.github/scripts/prepare-values.sh "charts/${{ needs.getChangedChart.outputs.chart }}"
- run: ./.github/scripts/create-values-diff.sh ${{ github.event.number }} "charts/${{ needs.getChangedChart.outputs.chart }}"

0 comments on commit 857dad7

Please sign in to comment.