Skip to content

add action for validating urls of recently modified yaml files #212

add action for validating urls of recently modified yaml files

add action for validating urls of recently modified yaml files #212

Workflow file for this run

name: Sc4pac CI
on:
push:
branches: [ "main", "action" ]
pull_request_target:
branches: [ "main" ]
workflow_dispatch: # for manually triggering the workflow from Actions tab
permissions:
contents: read
pages: write
id-token: write
jobs:
lint:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade PyYAML jsonschema
- name: Check sc4pac yaml schema (pull_request_target)
if: ${{ github.event_name == 'pull_request_target'}}
# With pull_request_target, the `main` branch is checked out, not the PR.
# We partially check out only src/yaml from the PR, the non-code part of the repository, as only that part is relevant for linting.
run: git checkout ${{ github.event.pull_request.head.ref}} -- src/yaml && make lint
- name: Check sc4pac yaml schema (push)
if: ${{ github.event_name != 'pull_request_target'}}
run: make lint
# requires STEX_API_KEY, so job is skipped in forks
url-check:
if: ${{ github.repository == 'memo33/sc4pac' }}
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
with:
# to allow partial-checkout/diff of other commit
fetch-depth: 0
- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.x'
- name: Install dependencies
run: python -m pip install --upgrade PyYAML jsonschema python-dateutil
- name: Check STEX URLs (pull_request_target)
if: ${{ github.event_name == 'pull_request_target'}}
env:
STEX_API_KEY: ${{ secrets.STEX_API_KEY }}
# we check out only src/yaml, the non-code part of the repository, and compare it to the current (base) branch
run: git checkout ${{ github.event.pull_request.head.ref}} -- src/yaml && sh .github/url-check.sh ${{ github.event.pull_request.base.ref }} src/yaml
- name: Check STEX URLs (push)
if: ${{ github.event_name == 'push'}}
env:
STEX_API_KEY: ${{ secrets.STEX_API_KEY }}
# TODO this is not perfect yet, as `before` sometimes does not exist
# run: sh .github/url-check.sh ${{ github.event.before }} src/yaml
run: sh .github/url-check.sh @~ src/yaml
deploy:
needs: lint # url-check is not needed as ST is flaky
if: ${{ github.repository == 'memo33/sc4pac' && github.ref == 'refs/heads/main' }}
environment:
name: github-pages
url: ${{ steps.deployment.outputs.page_url }}
runs-on: ubuntu-latest
# Allow only one concurrent deployment, skipping runs queued between the run in-progress and latest queued.
# However, do NOT cancel in-progress runs as we want to allow these production deployments to complete.
concurrency:
group: "pages"
cancel-in-progress: false
steps:
- name: Checkout
uses: actions/checkout@v4
with:
submodules: recursive
- name: Set up JDK 17
uses: actions/setup-java@v4
with:
java-version: '17'
distribution: 'temurin'
cache: 'sbt'
- uses: sbt/setup-sbt@v1
- name: Build sc4pac executable
run: cd sc4pac-tools && sbt assembly && ./sc4pac --version
- name: Build channel and website
run: make gh-pages-no-lint
- name: Setup Pages
uses: actions/configure-pages@v4
- name: Upload artifact
# note that this action dereferences our `latest` symlinks, but that's not a huge problem, it just duplicates each json file
uses: actions/upload-pages-artifact@v3
with:
path: "gh-pages"
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v4