-
Notifications
You must be signed in to change notification settings - Fork 0
53 lines (44 loc) · 1.5 KB
/
update-files.yml
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
# CI action that can either run:
# - via a manual trigger on a PR
# - every time a PR is updated
# The CI then then either updates the readme with a python script,
# or checks that it does not need update.
name: Update Files
on:
pull_request:
branches:
- main
types: [opened, synchronize, reopened]
workflow_dispatch:
jobs:
update-files:
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: '3.x'
- uses: extractions/setup-just@v1
with:
just-version: 1.35.0
- name: All files
run: just
- name: Check for changes
id: git-check
run: |
git diff --exit-code --name-only . || echo "changes=true" >> $GITHUB_OUTPUT
- name: Commit and push changes if manually triggered
if: github.event_name == 'workflow_dispatch' && steps.git-check.outputs.changes == 'true'
run: |
git config --local user.email "action@github.com"
git config --local user.name "GitHub Action"
git add .
git commit -m "Update files"
git push origin ${{ github.head_ref }}
- name: Error if changes needed on PR
if: github.event_name == 'pull_request' && steps.git-check.outputs.changes == 'true'
run: |
echo "Error: files need to be updated. Please run this workflow manually to update it."
exit 1