Skip to content

Commit

Permalink
ci: write up most parts
Browse files Browse the repository at this point in the history
  • Loading branch information
KisaragiEffective committed Apr 13, 2024
1 parent 5d7030d commit cbee533
Showing 1 changed file with 34 additions and 1 deletion.
35 changes: 34 additions & 1 deletion .github/workflows/validate-renovate.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,18 +6,51 @@ on:
- 'renovate.json'
- '.github/workflows/validate-renovate.yml'

permissions:
contents: read
issues: write

jobs:
actionlint:
name: actionlint with reviewdog
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: run lint
id: lint
run: |
# renovate: npm:renovate
ver="37.291.0"
# pinned on exact version
package="renovate@=$ver"
echo "npx: $(npx --version)"
echo "installing: $package..."
npx --yes --package "$package" -- renovate-config-validator --strict
H="$(mktemp)"
# let's do main part, but avoid pipefail
(npx --yes --package "$package" -- renovate-config-validator --strict || true)\
| ruby -e 'File.open(ENV[?H], ?w) {|r| while gets; puts $_; $> = r if $_.chomp == "WARN: Config migration necessary" ;end; }'
# init and extract
OLD="$(mktemp)"
mv "$OLD" "${OLD}.old.txt"
NEW="$(mktemp)"
mv "$NEW" "${NEW}.new.txt"
jq -rs '.old' < "$H" > "$OLD"
jq -rs '.new' < "$H" > "$NEW"
DIFF_TO_BE_REPORTED="$(mktemp)"
mv "$DIFF_TO_BE_REPORTED" "${DIFF_TO_BE_REPORTED}.diff"
git diff --no-index "$OLD" "$NEW" >> "$DIFF_TO_BE_REPORTED"
- name: report diff
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
DIFF_TEXT: ${{ steps.lint.outputs.DIFF }}
URL: ${{ github.event.pull_request.html_url }}
run:
COMMENT_BUFFER="$(mktemp)"

printf "I'm sorry, but this config should be migrated. Please apply following patch file to proceed:" >> "$COMMENT_BUFFER"
cat "$DIFF_TO_BE_REPORTED" >> "$COMMENT_BUFFER"

gh pr comment -F "$COMMENT_BUFFER" "${URL}"

0 comments on commit cbee533

Please sign in to comment.