Skip to content

fix(ci): add escapes for [ and ] to allow renovatebot trigger mock-rock #388

fix(ci): add escapes for [ and ] to allow renovatebot trigger mock-rock

fix(ci): add escapes for [ and ] to allow renovatebot trigger mock-rock #388

Workflow file for this run

name: PR Validator
on:
pull_request:
paths:
- "oci/*/*.y*ml"
jobs:
get-submitted-files:
runs-on: ubuntu-22.04
name: Get submitted files
outputs:
changed-files-matrix: ${{ steps.changed-files-matrix.outputs.matrix }}
image-name: ${{ steps.changed-files-dir-names.outputs.all_changed_files }}
steps:
- uses: actions/checkout@v4
- name: Get changed files
id: changed-files
uses: tj-actions/changed-files@v35
with:
json: true
files: |
oci/*/*.y*ml
- name: Get image name
id: changed-files-dir-names
uses: tj-actions/changed-files@v35
with:
dir_names: "true"
files: |
oci/*/*.y*ml
- name: Only 1 image can be changed per PR
run: |
set -eux
dir_names="${{ steps.changed-files-dir-names.outputs.all_changed_files }}"
echo "Can only modify 1 image per PR"
(( $(echo "${dir_names}" | wc -w) == 1 ))
- name: Save matrix layout for file validation
id: changed-files-matrix
run: |
echo 'Changed files are: ${{ steps.changed-files.outputs.all_changed_files }}'
echo "matrix={\"filename\":${{ steps.changed-files.outputs.all_changed_files }}}" >> "$GITHUB_OUTPUT"
check-missing-files:
runs-on: ubuntu-22.04
name: Check for missing files
needs: [get-submitted-files]
# temporarily continue on error, until the Notification and Doc update jobs are set
continue-on-error: true
steps:
- uses: actions/checkout@v4
- name: Check if documentation.yaml exists
uses: andstor/file-existence-action@v2
with:
files: "${{ needs.get-submitted-files.outputs.image-name }}/documentation.yaml"
fail: true
- name: Check if contacts.yaml exists
uses: andstor/file-existence-action@v2
with:
files: "${{ needs.get-submitted-files.outputs.image-name }}/contacts.yaml"
fail: true
validate-submitted-files:
runs-on: ubuntu-22.04
name: Validate files
needs: [get-submitted-files]
strategy:
fail-fast: true
matrix: ${{ fromJSON(needs.get-submitted-files.outputs.changed-files-matrix) }}
steps:
- uses: actions/checkout@v4
- uses: actions/setup-python@v5
with:
python-version: "3.x"
- name: Validate YAML format
run: |
set -eux
pip install yamllint
yamllint -c .yamllint.yaml ${{ matrix.filename }}
- name: Validate documentation trigger file
if: ${{ contains(matrix.filename, 'documentation.yaml') }}
run: |
pip install -r src/docs/requirements.txt
python3 -c '
import src.docs.generate_oci_doc_yaml as OCIDoc
OCIDoc.OCIDocumentationData.read_documentation_yaml("${{ matrix.filename }}")
'
update-pr:
runs-on: ubuntu-22.04
name: Add comment to PR
needs: [get-submitted-files, check-missing-files, validate-submitted-files]
if: ${{ always() && contains(needs.*.result, 'failure') }}
permissions:
pull-requests: write
steps:
- uses: actions/checkout@v4
- name: Comment PR
uses: thollander/actions-comment-pull-request@v2
with:
message: |
One or more files in this PR are not valid! :grimacing:
_Run ID: **${{ github.run_id }}** ; Attempt: **${{ github.run_attempt }}**_
See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
reactions: eyes