-
Notifications
You must be signed in to change notification settings - Fork 15
73 lines (71 loc) · 2.2 KB
/
auto_update.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
name: Auto update
on:
schedule:
- cron: "20 4,16 * * *"
workflow_dispatch:
jobs:
auto-update:
name: Auto update
runs-on: ubuntu-latest
outputs:
new-firmwares: ${{ steps.changes.outputs.firmwares }}
steps:
- name: Checkout repo
uses: actions/checkout@v3
with:
persist-credentials: false
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
cache: pip
- name: Install dependencies
run: |
sudo apt install zlib1g-dev liblzo2-dev -y
python -m pip install --upgrade pip
python -m pip install -r requirements.txt
- name: Create local changes
id: changes
run: echo "firmwares=$(python main.py update -g)" >> $GITHUB_OUTPUT
- name: Commit files
continue-on-error: true
run: |
git config --local user.email "41898282+github-actions[bot]@users.noreply.github.com"
git config --local user.name "github-actions[bot]"
git commit -a -m "Auto update"
- name: Push changes
uses: ad-m/github-push-action@master
with:
github_token: ${{ secrets.GITHUB_TOKEN }}
branch: ${{ github.ref }}
release:
runs-on: ubuntu-latest
needs: auto-update
if: success() && fromJSON(needs.auto-update.outputs.new-firmwares)
permissions:
contents: write
steps:
- name: Checkout repo
uses: actions/checkout@v3 # https://github.com/actions/checkout/issues/439
with:
fetch-depth: 0
ref: main
- name: Set up Python
uses: actions/setup-python@v4
with:
python-version: "3.11"
- name: Create release body
run: python release.py '${{ needs.auto-update.outputs.new-firmwares }}'
- name: Get time and date
run: |
echo "DATE=$(date +%Y.%m.%d -u)" >> $GITHUB_ENV
echo "UNIX_TS=$(date +%s)" >> $GITHUB_ENV
- name: Create release
uses: ncipollo/release-action@v1
with:
tag: ${{ env.UNIX_TS }}
name: ${{ env.DATE }}
bodyFile: body.md
commit: main
makeLatest: true