Run and Deploy #428
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: Run and Deploy | |
on: | |
push: | |
branches: | |
- 'main' | |
pull_request: | |
# Allow manual runs through the web UI | |
workflow_dispatch: | |
schedule: | |
# ┌───────── minute (0 - 59) | |
# │ ┌───────── hour (0 - 23) | |
# │ │ ┌───────── day of the month (1 - 31) | |
# │ │ │ ┌───────── month (1 - 12 or JAN-DEC) | |
# │ │ │ │ ┌───────── day of the week (0 - 6 or SUN-SAT) | |
- cron: '0 0 * * *' # Every day at 00:00 UTC | |
concurrency: | |
group: ${{ github.workflow }}-${{ github.ref }} | |
cancel-in-progress: true | |
jobs: | |
check_style: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install tox | |
- name: Check Style | |
run: | | |
tox -e codestyle | |
run_script: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Set up Python 3.11 | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
- name: Install dependencies | |
run: | | |
python -m pip install tox | |
- name: Run Script | |
run: | | |
tox -e py311 | |
- name: Upload artifacts | |
uses: actions/upload-artifact@v4 | |
with: | |
name: files | |
path: | | |
timeline* | |
deploy: | |
needs: [run_script] | |
if: | | |
( | |
github.event_name != 'pull_request' && ( | |
github.ref_name == 'main' || | |
github.event_name == 'workflow_dispatch' | |
) | |
) | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Get current date | |
id: date | |
run: echo "::set-output name=date::$(date +'%Y%m%d')" | |
- name: Download all workflow run artifacts | |
uses: actions/download-artifact@v4 | |
with: | |
name: files | |
path: ~/files | |
- name: Display structure of downloaded files | |
run: ls -R | |
working-directory: /home/runner/files | |
- name: Upload files then create tag and release | |
uses: ncipollo/release-action@v1 | |
with: | |
name: Timeline created on ${{ steps.date.outputs.date }} | |
tag: ${{ steps.date.outputs.date }} | |
artifacts: "/home/runner/files/*" | |
replacesArtifacts: true | |
makeLatest: true | |
artifactErrorsFailBuild: true | |
allowUpdates: true | |
token: ${{ secrets.SDOTIMELINE }} | |
- name: Checkout csv to json repository | |
uses: actions/checkout@v4 | |
with: | |
repository: 'derekeder/csv-to-html-table' | |
ref: 'master' | |
path: 'csv_to_html' | |
- name: Move files to csv_to_html | |
run: | | |
mv /home/runner/files/timeline_${{ steps.date.outputs.date }}.csv /home/runner/work/SDO-Timeline/SDO-Timeline/csv_to_html/data/timeline.csv | |
mv /home/runner/work/SDO-Timeline/SDO-Timeline/index.html /home/runner/work/SDO-Timeline/SDO-Timeline/csv_to_html/ | |
- name: Deploy to GitHub Pages | |
uses: peaceiris/actions-gh-pages@v4 | |
with: | |
github_token: ${{ secrets.SDOTIMELINE }} | |
publish_dir: "/home/runner/work/SDO-Timeline/SDO-Timeline/csv_to_html/" | |
force_orphan: true |