Auto update #496
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |