Skip to content

Commit

Permalink
ci: test
Browse files Browse the repository at this point in the history
  • Loading branch information
kasper93 committed Oct 21, 2024
1 parent 7658510 commit fbefebb
Showing 1 changed file with 25 additions and 37 deletions.
62 changes: 25 additions & 37 deletions .github/workflows/comment.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,42 +6,30 @@ on:
types: [completed]

jobs:
pr_comment:
if: github.event.workflow_run.event == 'pull_request' &&
github.event.workflow_run.conclusion == 'success' &&
github.event.pull_request.state == 'open'
dump_contexts_to_log:
runs-on: ubuntu-latest
steps:
- env:
GH_REPO: ${{ github.repository }}
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
pr=$(gh pr list --state open --json headRefOid,number \
--jq '.[] | select(.headRefOid == "${{ github.event.workflow_run.head_sha }}") | .number')
if [ -z "$pr" ]; then
echo "No matching pull request found"
exit 1
fi
artifacts=$(gh api repos/{owner}/{repo}/actions/runs/${{ github.event.workflow_run.id }}/artifacts --jq '.artifacts')
if [ "$(echo "$artifacts" | jq 'length')" -eq 0 ]; then
echo "No artifacts found"
exit 0
fi
body=$(echo "$artifacts" | jq -r '
def link: "https://nightly.link/${{ github.repository }}/actions/artifacts/\(.id).zip";
def entry: "* [\(.name)](\(link))";
"Download the artifacts for this pull request:\n<details><summary>Windows</summary>\n\n" +
(sort_by(.name) | map(select(.name | test("w64|msvc")) | entry) | join("\n")) +
"\n</details>\n<details><summary>macOS</summary>\n\n" +
(sort_by(.name) | map(select(.name | test("macos")) | entry) | join("\n")) +
"\n</details>"
')
comment_id=$(gh issue view $pr --json comments \
--jq '.comments[] | select(.author.login == "github-actions") | .id')
if [ -n "$comment_id" ]; then
edit=--edit-last
fi
gh pr comment $pr --body "$body" $edit
- name: Dump GitHub context
env:
GITHUB_CONTEXT: ${{ toJson(github) }}
run: echo "$GITHUB_CONTEXT"
- name: Dump job context
env:
JOB_CONTEXT: ${{ toJson(job) }}
run: echo "$JOB_CONTEXT"
- name: Dump steps context
env:
STEPS_CONTEXT: ${{ toJson(steps) }}
run: echo "$STEPS_CONTEXT"
- name: Dump runner context
env:
RUNNER_CONTEXT: ${{ toJson(runner) }}
run: echo "$RUNNER_CONTEXT"
- name: Dump strategy context
env:
STRATEGY_CONTEXT: ${{ toJson(strategy) }}
run: echo "$STRATEGY_CONTEXT"
- name: Dump matrix context
env:
MATRIX_CONTEXT: ${{ toJson(matrix) }}
run: echo "$MATRIX_CONTEXT"

0 comments on commit fbefebb

Please sign in to comment.