What's the next? #44
This file contains 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 characters
name: Diff | |
on: | |
issue_comment: | |
types: [created] | |
jobs: | |
debug: | |
runs-on: ubuntu-latest | |
needs: [diff, generate, summary] | |
if: always() && (vars.ACTIONS_RUNNER_DEBUG || vars.ACTIONS_STEP_DEBUG ) | |
steps: | |
- name: echo needs | |
run: echo '${{ toJson(needs) }}' | |
- name: echo github | |
run: echo '${{ toJson(github) }}' | |
- name: echo pull request | |
run: echo '${{ github.event.issue.pull_request == 'true' }}' | |
- name: echo comment association | |
run: echo '${{ github.event.comment.author_association }} - ${{ github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER' }}' | |
- name: echo comment body | |
run: echo '${{ contains(github.event.comment.body, '\n/ci') || startsWith(github.event.comment.body, '/ci') }}' | |
- name: echo generate diffs | |
run: echo '${{ needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != '' }}' | |
- name: echo generate result | |
run: echo '${{ needs.generate.result == 'success' }}' | |
generate: | |
runs-on: ubuntu-latest | |
outputs: | |
diffs: ${{ steps.regress-ci.outputs.diffs }} | |
if: github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && (contains(github.event.comment.body, '\n/ci') || startsWith(github.event.comment.body, '/ci')) | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "diff" | |
- run: cargo regress ci | |
id: regress-ci | |
env: | |
GITHUB_COMMENT: ${{ github.event.comment.body }} | |
GITHUB_COMMENT_PR: ${{ github.event.comment.issue_url }} | |
diff: | |
runs-on: ubuntu-latest | |
needs: [generate] | |
if: needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != '' | |
strategy: | |
matrix: | |
include: ${{ fromJson(needs.generate.outputs.diffs) }} | |
steps: | |
- uses: actions/checkout@v4 | |
- uses: dtolnay/rust-toolchain@master | |
with: | |
toolchain: stable | |
- name: Cache | |
uses: Swatinem/rust-cache@v2 | |
with: | |
shared-key: "diff" | |
- uses: taiki-e/install-action@v2 | |
if: matrix.needs_semver_checks | |
with: | |
tool: cargo-semver-checks | |
# if a new line is added here, make sure to update the `summary` job to reference the new step index | |
- uses: taiki-e/install-action@v2 | |
with: | |
tool: git-delta | |
- run: cargo regress diff --use-pager-directly ${{ matrix.command }} | |
env: | |
GH_TOKEN: ${{ github.token }} | |
GITHUB_PR: ${{ matrix.pr }} | |
GIT_PAGER: delta --hunk-header-style omit | |
summary: | |
runs-on: ubuntu-latest | |
needs: [diff, generate] | |
if: always() && needs.generate.outputs.diffs != '{}' && needs.generate.outputs.diffs != '[]' && needs.generate.outputs.diffs != '' && needs.generate.result == 'success' | |
steps: | |
- uses: actions/checkout@v4 | |
- run: | | |
PR_ID=$(echo "${{ github.event.comment.issue_url }}" | grep -o '[0-9]\+$') | |
gh run view ${{ github.run_id }} --json jobs | \ | |
jq -r '"Diff for [comment]("+$comment+")\n\n" + ([.jobs[] | select(.name | startswith("diff")) | "- [" + (.name | capture("\\((?<name>[^,]+),.*") | .name) + "](" + .url + "?pr=" + $pr_id + "#step:7:45)"] | join("\n"))' --arg pr_id "$PR_ID" --arg comment "${{ github.event.comment.url }}"| \ | |
gh pr comment "$PR_ID" --body "$(< /dev/stdin)" | |
env: | |
GH_TOKEN: ${{ github.token }} |