Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

WIP #89

Closed
wants to merge 5 commits into from
Closed

WIP #89

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
77 changes: 77 additions & 0 deletions .github/workflows/comment_pr_diff.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# comment_pr_diff.yml
# From https://github.com/orgs/community/discussions/51403z
name: Comment Artifact Diff files URL on PR

on:
workflow_run:
types:
- "completed"
workflows:
- "Diff"

jobs:
comment-on-pr:
if: github.event.workflow_run.conclusion == 'success'
runs-on: ubuntu-latest
steps:
- name: Test
run: |
pwd

- name: Get Artifact URL & PR Info
env:
GITHUB_TOKEN: ${{ github.token }}
OWNER: ${{ github.repository_owner }}
REPO: ${{ github.event.repository.name }}
WORKFLOW_RUN_EVENT_OBJ: ${{ toJSON(github.event.workflow_run) }}
run: |

PREVIOUS_JOB_ID=$(jq -r '.id' <<< "$WORKFLOW_RUN_EVENT_OBJ")
echo "Previous Job ID: $PREVIOUS_JOB_ID"
echo "PREVIOUS_JOB_ID=$PREVIOUS_JOB_ID" >> "$GITHUB_ENV"

ARTIFACT_URL=$(gh api "/repos/$OWNER/$REPO/actions/artifacts" \
--jq ".artifacts.[] |
select(.workflow_run.id==${PREVIOUS_JOB_ID}) |
select(.expired==false) |
.archive_download_url")

echo "ARTIFACT URL: $ARTIFACT_URL"
echo "ARTIFACT_URL=$ARTIFACT_URL" >> "$GITHUB_ENV"

PR_NUMBER=$(jq -r '.pull_requests[0].number' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "PR Number: $PR_NUMBER"
echo "PR_NUMBER=$PR_NUMBER" >> "$GITHUB_ENV"

HEAD_SHA=$(jq -r '.pull_requests[0].head.sha' \
<<< "$WORKFLOW_RUN_EVENT_OBJ")

echo "Head sha: $HEAD_SHA"
echo "HEAD_SHA=$HEAD_SHA" >> "$GITHUB_ENV"

- name: Update Comment
env:
JOB_PATH: "${{ github.server_url }}/${{ github.repository }}/actions/\
runs/${{ env.PREVIOUS_JOB_ID }}"
HEAD_SHA: ${{ env.HEAD_SHA }}
uses: peter-evans/create-or-update-comment@v2
with:
issue-number: ${{ env.PR_NUMBER }}
body: |-
## Diff ASDF preview files are ready!

[![badge]]($JOB_PATH)

You can find files attached to the below linked Workflow Run URL (Logs).

| Name | Link
--------------------------------------------------------------------
| Commit | ${{ env.HEAD_SHA }}

| Logs | ${{ env.JOB_PATH }}

| Jar Files | ${{ env. ARTIFACT_URL }}

[badge]: https://img.shields.io/badge/Build-Success!-3fb950?logo=github&style=for-the-badge
8 changes: 4 additions & 4 deletions .github/workflows/diff.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,22 +25,22 @@ jobs:

- name: Create schematics diff
run: |
kicad-diff.py original/project/ZSWatch.kicad_sch modified/project/ZSWatch.kicad_sch --diff_mode red_green --all_pages --output_dir diff-schematics --no_reader --keep_pngs --resolution 500
kicad-diff.py original/project/ZSWatch.kicad_sch modified/project/ZSWatch.kicad_sch --diff_mode red_green --all_pages --output_dir diff-schematics --no_reader --keep_pngs --resolution 400

- name: Create layout diff
run: |
kicad-diff.py original/project/ZSWatch.kicad_pcb modified/project/ZSWatch.kicad_pcb --diff_mode red_green --all_pages --output_dir diff-layout --no_reader --keep_pngs --resolution 500
kicad-diff.py original/project/ZSWatch.kicad_pcb modified/project/ZSWatch.kicad_pcb --diff_mode red_green --all_pages --output_dir diff-layout --no_reader --keep_pngs --resolution 400

- name: Upload Layout Diff
uses: actions/upload-artifact@v4
with:
name: "diff-layout-master-${{ github.ref_name }}"
name: "diff-layout-${{ github.ref_name }}"
path: diff-layout
if-no-files-found: ignore

- name: Upload Schematics Diff
uses: actions/upload-artifact@v4
with:
name: "diff-schematics-master-${{ github.ref_name }}"
name: "diff-schematics-${{ github.ref_name }}"
path: diff-schematics
if-no-files-found: ignore
2 changes: 2 additions & 0 deletions .github/workflows/production.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ on:
pull_request_target:
types:
- closed
- pull_request
- push

jobs:
build:
Expand Down