Web #3035
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: Web | |
on: | |
workflow_dispatch: | |
inputs: | |
sales: | |
type: string | |
description: | | |
Comma separated values of the games to explicitly refresh. | |
Resumes refresh from previous end point if left empty. | |
Example (without apostrophes): '2, 5, 88888' | |
required: false | |
restart_from_sale_id: | |
type: string | |
description: | | |
Rechecks every sale starting form the given ID. | |
This should only be used after a fix in code. | |
Example (without apostrophes): '113801' | |
required: false | |
schedule: | |
- cron: '18 0,6,12,18 * * *' | |
push: | |
branches: | |
- master | |
pull_request: | |
branches: | |
- master | |
jobs: | |
# Build job | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v4 | |
- name: Install Python | |
uses: actions/setup-python@v5 | |
with: | |
python-version: '3.11' | |
cache: 'pip' | |
- name: Install Dependencies | |
run: pip install -r requirements.txt | |
shell: bash | |
- name: Get current date | |
id: date | |
run: echo "date=$(date +'%Y-%m-%d--%H-%M-%S')" >> $GITHUB_OUTPUT | |
- name: Persist previously collected sales | |
uses: actions/cache@v4 | |
env: | |
cache-name: sale-data-v1.1 | |
with: | |
path: web/data/ | |
key: ${{ env.cache-name }}-${{ steps.date.outputs.date }} | |
restore-keys: | | |
${{ env.cache-name }} | |
- name: Change resume_index to user's input value | |
if: github.event_name == 'workflow_dispatch' && github.event.inputs.restart_from_sale_id != '' | |
run: echo ${{ github.event.inputs.restart_from_sale_id }} > web/data/resume_index.txt | |
- name: Refresh sales from itch.io | |
run: python itchclaim.py refresh_sale_cache --games_dir web/data/ --sales "[${{ github.event.inputs.sales }}]" | |
- name: Generate index.html and JSON data | |
run: python itchclaim.py generate_web --web_dir web/ | |
- name: Upload Page | |
uses: actions/upload-pages-artifact@v3 | |
with: | |
path: web/ | |
# Deploy job | |
deploy: | |
# Add a dependency to the build job | |
needs: build | |
# Don't deploy pull requests | |
if: github.event_name != 'pull_request' | |
# Grant GITHUB_TOKEN the permissions required to make a Pages deployment | |
permissions: | |
pages: write # to deploy to Pages | |
id-token: write # to verify the deployment originates from an appropriate source | |
# Deploy to the github-pages environment | |
environment: | |
name: github-pages | |
url: ${{ steps.deployment.outputs.page_url }} | |
# Specify runner + deployment step | |
runs-on: ubuntu-latest | |
steps: | |
- name: Deploy to GitHub Pages | |
id: deployment | |
uses: actions/deploy-pages@v4 |