Manual F1 database updater #13
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: Manual F1 database updater | |
on: | |
workflow_dispatch: | |
jobs: | |
caller: | |
runs-on: ubuntu-latest | |
outputs: | |
run_id: ${{ steps.return_dispatch.outputs.run_id }} | |
steps: | |
- name: Dispatch an action and get the run ID | |
uses: codex-/return-dispatch@v1 | |
id: return_dispatch | |
with: | |
token: ${{ secrets.UPDATER_PAT }} | |
ref: main | |
repo: f1-data-updater | |
owner: race-tech | |
workflow: main.yml | |
- name: Await Run ID ${{ steps.return_dispatch.outputs.run_id }} | |
uses: codex-/await-remote-run@v1 | |
with: | |
token: ${{ secrets.UPDATER_PAT }} | |
repo: f1-data-updater | |
owner: race-tech | |
run_id: ${{ steps.return_dispatch.outputs.run_id }} | |
run_timeout_seconds: 600 | |
poll_interval_ms: 5000 | |
checker: | |
runs-on: ubuntu-latest | |
needs: caller | |
outputs: | |
run_id: ${{ needs.caller.outputs.run_id }} | |
artifact_exists: ${{ steps.check.outputs.artifact_exists }} | |
steps: | |
- name: Check if a new artifact has been created | |
id: check | |
uses: thibault-cne/check-artifacts@v1 | |
with: | |
token: ${{ secrets.UPDATER_PAT }} | |
repo: f1-data-updater | |
owner: race-tech | |
run_id: ${{ needs.caller.outputs.run_id }} | |
name: f1db.sql.gz | |
updater: | |
runs-on: ubuntu-latest | |
needs: checker | |
if: needs.checker.outputs.artifact_exists == 'true' | |
permissions: | |
contents: read | |
packages: write | |
steps: | |
- name: Checkout repository | |
uses: actions/checkout@v4 | |
- name: Dowload SQL dump | |
uses: actions/download-artifact@v4 | |
with: | |
name: f1db.sql.gz | |
github-token: ${{ secrets.UPDATER_PAT }} | |
repository: race-tech/f1-data-updater | |
run-id: ${{ needs.checker.outputs.run_id }} | |
- name: Docker meta | |
id: meta | |
uses: docker/metadata-action@v5 | |
with: | |
# list of Docker images to use as base name for tags | |
images: | | |
ghcr.io/race-tech/f1-db | |
# generate Docker tags based on the following events/attributes | |
tags: | | |
type=schedule,pattern={{date 'YYYYMMDD'}} | |
type=raw,value=latest | |
- name: Set up QEMU | |
uses: docker/setup-qemu-action@v3 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v3 | |
- name: Login to GitHub Container Registry | |
uses: docker/login-action@v3 | |
with: | |
registry: ghcr.io | |
username: "${{ github.actor }}" | |
password: ${{ secrets.GITHUB_TOKEN }} | |
- name: Build and push | |
uses: docker/build-push-action@v6 | |
with: | |
file: resources/dockerfiles/database/Dockerfile | |
context: . | |
platforms: linux/amd64,linux/arm64 | |
push: true | |
tags: ${{ steps.meta.outputs.tags }} | |
cache-from: type=gha | |
cache-to: type=gha,mode=max |