Skip to content

chore: set jre rocks eol #845

chore: set jre rocks eol

chore: set jre rocks eol #845

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@531f5f7d163941f0c1c04e0ff4d8bb243ac4366f
with:
json: true
files: |
oci/*/*.y*ml
- name: Get image name
id: changed-files-dir-names
uses: tj-actions/changed-files@531f5f7d163941f0c1c04e0ff4d8bb243ac4366f
with:
dir_names: "true"
files: |
oci/*/*.y*ml
- name: Only 1 image can be changed per PR
run: |
set -e
if [[ "$RUNNER_DEBUG" == "1" ]]; then
set -x
fi
source src/shared/logs.sh
set -u
dir_names="${{ steps.changed-files-dir-names.outputs.all_changed_files }}"
log_error "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: |
source src/shared/logs.sh
log_info '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 -e
if [[ "$RUNNER_DEBUG" == "1" ]]; then
set -x
fi
set -u
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 }}")
'
validate-registry-has-repo:
runs-on: ubuntu-latest
name: Validate registry has repo
needs: [get-submitted-files]
permissions:
pull-requests: write
env:
IS_PROD: ${{ ! startsWith(needs.get-submitted-files.outputs.image-name, 'mock-') }}
COMMENT_TAG: "repo-not-exist"
steps:
- name: Validate registry has repo
id: validate-registry-has-repo
env:
NAMESPACE: ${{ env.IS_PROD == 'true' && 'ubuntu' || 'rocksdev' }}
run: |
DOCKER_REPO_EXISTS='true'
if curl -w "%{http_code}" -o /dev/null -s \
https://hub.docker.com/v2/repositories/$NAMESPACE/$(basename ${{ needs.get-submitted-files.outputs.image-name }}) \
| grep -qv "200" ; then
DOCKER_REPO_EXISTS='false'
fi
echo "docker-repo-exists=${DOCKER_REPO_EXISTS}" >> "$GITHUB_OUTPUT"
- name: Comment PR if repo does not exist
if: ${{ steps.validate-registry-has-repo.outputs.docker-repo-exists == 'false' }}
uses: thollander/actions-comment-pull-request@v2
with:
message: |
The Docker repository for this image does not exist yet. Merging of this repo is blocked.
_Run ID: **${{ github.run_id }}** ; Attempt: **${{ github.run_attempt }}**_
See [logs](${{ github.server_url }}/${{ github.repository }}/actions/runs/${{ github.run_id }}).
reactions: eyes
comment_tag: ${{ env.COMMENT_TAG }}
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