2024-05-07-clml #605
Workflow file for this run
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: filter-files | |
on: | |
pull_request: | |
branches: | |
- main | |
# hack for https://github.com/actions/cache/issues/810#issuecomment-1222550359 | |
#env: | |
# SEGMENT_DOWNLOAD_TIMEOUT_MIN: 3 | |
jobs: | |
files-changed: | |
name: Detect what files changed | |
# if: contains(github.event.pull_request.labels.*.name, 'submission') | |
# if: ${{ github.event.label.name == 'submission' }} | |
runs-on: ubuntu-20.04 | |
timeout-minutes: 3 | |
outputs: | |
offendingfiles: ${{ steps.pythonfilter.outputs.offendingfiles }} | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v3 | |
- uses: actions/setup-python@v4 | |
with: | |
python-version: '3.10' | |
- run: pip install python-slugify pyyaml | |
- uses: dorny/paths-filter@v2 | |
id: filter | |
with: | |
# Enable listing of files matching each filter. | |
# Paths to files will be available in `${FILTER_NAME}_files` output variable. | |
# Paths will be escaped and space-delimited. | |
# Output is usable as command-line argument list in Linux shell | |
list-files: shell | |
# In this example changed files will be checked by linter. | |
# It doesn't make sense to lint deleted files. | |
# Therefore we specify we are only interested in added or modified files. | |
filters: | | |
changed: | |
- '**' | |
- name: Check label | |
run: echo ${{ github.event.label.name }} | |
- name: Save title slug | |
run: echo "SLUG=`slugify ${{ github.event.pull_request.title }}`" >> $GITHUB_ENV | |
- name: Print slug | |
run: echo ${{env.SLUG}} | |
- name: Check if changed files fit our filters | |
id: pythonfilter | |
if: ${{ steps.filter.outputs.changed == 'true' }} | |
# todo read from step below | |
run: | | |
FILTEROUT=$(python3 bin/filterpaths.py $SLUG ${{ steps.filter.outputs.changed_files }} | tail -1) | |
echo "offendingfiles=$FILTEROUT" >> $GITHUB_OUTPUT | |
mkdir site_out | |
python3 bin/filterpaths.py $SLUG ${{ steps.filter.outputs.changed_files }} | |
#- uses: actions/github-script@v6 | |
# if: always() && steps.pythonfilter.outcome == 'failure' | |
# with: | |
# script: | | |
# github.rest.issues.createComment({ | |
# issue_number: context.issue.number, | |
# owner: context.repo.owner, | |
# repo: context.repo.repo, | |
# body: "⚠️ **We have detected a problem with your submission!** ⚠️\n\n${{ steps.pythonfilter.outputs.offendingfiles }}\n\nPlease make the aforementioned changes and re-submit :)" | |
# }) | |
- name: Setup Ruby | |
if: always() && steps.pythonfilter.outcome == 'success' | |
uses: ruby/setup-ruby@v1 | |
with: | |
ruby-version: '3.0.2' | |
bundler-cache: true | |
- name: Install deps | |
if: always() && steps.pythonfilter.outcome == 'success' | |
run: | | |
npm install -g mermaid.cli | |
- name: Setup deploy options | |
if: always() && steps.pythonfilter.outcome == 'success' | |
id: setup | |
run: | | |
git config --global user.name "GitHub Action" | |
git config --global user.email "41898282+github-actions[bot]@users.noreply.github.com" | |
if [[ ${GITHUB_REF} = refs/pull/*/merge ]]; then # pull request | |
echo "SRC_BRANCH=${GITHUB_HEAD_REF}" >> $GITHUB_OUTPUT | |
echo "NO_PUSH=--no-push" >> $GITHUB_OUTPUT | |
elif [[ ${GITHUB_REF} = refs/heads/* ]]; then # branch, e.g. master, source etc | |
echo "SRC_BRANCH=${GITHUB_REF#refs/heads/}" >> $GITHUB_OUTPUT | |
fi | |
echo "DEPLOY_BRANCH=gh-pages" >> $GITHUB_OUTPUT | |
- name: Build website | |
if: always() && steps.pythonfilter.outcome == 'success' | |
run: yes | bash bin/build --verbose ${{ steps.setup.outputs.NO_PUSH }} | |
--src ${{ steps.setup.outputs.SRC_BRANCH }} | |
--deploy ${{ steps.setup.outputs.DEPLOY_BRANCH }} | |
--slug ${{env.SLUG}}-${{ github.event.number }} | |
- name: Save slug | |
if: always() | |
run: echo ${{env.SLUG}} > site_out/slug.txt | |
- name: Save PR number | |
if: always() | |
env: | |
PR_NUMBER: ${{ github.event.number }} | |
run: echo $PR_NUMBER > site_out/pr_number.txt | |
- name: Save filterout | |
if: always() | |
run: echo "${{ steps.pythonfilter.outputs.offendingfiles }}" > site_out/filterout.txt | |
- uses: actions/upload-artifact@v2 | |
if: always() | |
with: | |
name: website_out | |
path: site_out |