-
Notifications
You must be signed in to change notification settings - Fork 0
79 lines (67 loc) · 2.44 KB
/
update-schematic-pdfs.yaml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
name: Update Schematic PDFs
on:
push: # Trigger for pushes.
branches:
- main
paths:
- hardware/**
- .github/workflows/update-schematic-pdfs.yaml
pull_request_target: # Trigger for pull requests, but in context of main.
types: [opened, synchronize, reopened, ready_for_review]
workflow_dispatch: # Allows for manual triggering.
# If another instance of this workflow is started for the same PR, cancel the
# old one. If a PR is updated and a new test run is started, the old test run
# will be cancelled automatically to conserve resources and to avoid a race
# updating the PR.
concurrency:
group: update-schematic-pdfs-${{ github.event.pull_request.number }}
cancel-in-progress: true
permissions:
contents: write
pull-requests: write
jobs:
update:
name: Update Schematic PDFs
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v4
with:
# Get code from main to run the KiCad action, so it cannot be
# controlled by an attacker uploading a malicious PR.
ref: main
- name: Install KiCad
uses: ./.github/workflows/install-kicad
- name: Checkout PR
if: github.event_name == 'pull_request_target'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: gh pr checkout ${{ github.event.pull_request.number }}
- name: Install libfaketime
run: sudo apt install libfaketime
- name: Generate schematic PDFs
id: generate
run: |
cd hardware
./update-pdfs.sh cart
./update-pdfs.sh microcontroller
./update-pdfs.sh sram-bank
if git diff --exit-code *.pdf; then
echo "needs-update=" >> $GITHUB_OUTPUT
echo "No changes to PDFs."
else
echo "needs-update=true" >> $GITHUB_OUTPUT
git add *.pdf
git config --local user.email "[email protected]"
git config --local user.name "Kinetoscope Bot"
git commit -m "Update schematic PDFs"
fi
- name: Update Branch
if: steps.generate.outputs.needs-update == 'true'
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
run: |
git push -f origin HEAD:update-schematic-pdfs
gh pr create -B main -H update-schematic-pdfs \
--title "Update schematic PDFs" \
--body "Generated by GitHub Actions" || true