Daily Update and Deploy #191
This file contains hidden or 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: Daily Update and Deploy | |
on: | |
schedule: | |
# Run daily at midnight UTC | |
- cron: '0 0 * * *' | |
# Allow manual triggering | |
workflow_dispatch: | |
# Sets permissions of the GITHUB_TOKEN to allow deployment to GitHub Pages | |
permissions: | |
contents: write | |
pages: write | |
id-token: write | |
# Allow only one concurrent deployment | |
concurrency: | |
group: "pages" | |
cancel-in-progress: false | |
jobs: | |
update-and-build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
with: | |
# Fetch all history for proper GitHub Pages deployment | |
fetch-depth: 0 | |
# Ensure submodules are checked out | |
submodules: 'recursive' | |
- name: Set up Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.x' | |
- name: Update submodules | |
run: | | |
git config --global user.name "GitHub Actions Bot" | |
git config --global user.email "[email protected]" | |
git submodule init | |
git submodule update --recursive | |
cd Wippersnapper_Boards | |
git reset --hard origin/offline-mode | |
cd ../Wippersnapper_Components | |
git reset --hard origin/offline-mode | |
cd .. | |
git add Wippersnapper_Boards Wippersnapper_Components | |
git diff --staged --quiet || git commit -m "Update submodules to latest versions [skip ci]" | |
- name: Run conversion script | |
run: | | |
pip install -r requirements.txt | |
python convert_all_wippersnapper_definitions.py | |
- name: Commit changes if any | |
run: | | |
git add wippersnapper_boards.json wippersnapper_components.json wippersnapper_boards.js wippersnapper_components.js firmware-data.js | |
git diff --staged --quiet || git commit -m "Auto-update Wippersnapper definitions [skip ci]" | |
git push origin ${{ github.ref_name }} | |
- name: Setup Pages | |
uses: actions/configure-pages@v4 | |
- name: Upload artifact | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: '.' | |
# Deploy job | |
deploy: | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
runs-on: ubuntu-latest | |
needs: update-and-build | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |