From 028b348d20ede8029149993826df9481c0820d86 Mon Sep 17 00:00:00 2001 From: Zuzana Miklankova Date: Tue, 26 Mar 2024 14:25:25 +0100 Subject: [PATCH] is generator: add composite action for checking generated files --- ocp-stream-generator/action.yml | 55 +++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 ocp-stream-generator/action.yml diff --git a/ocp-stream-generator/action.yml b/ocp-stream-generator/action.yml new file mode 100644 index 0000000..4e3df94 --- /dev/null +++ b/ocp-stream-generator/action.yml @@ -0,0 +1,55 @@ +--- +name: Imagestreamfiles check +description: "Check imagestream generator generated files" + +inputs: + ref: + description: ref of the PR + required: true + +runs: + using: composite + steps: + - name: Checkout repo + uses: actions/checkout@v4 + with: + ref: ${{ inputs.ref }} + + - name: Clone ci-script repo, install deps + shell: bash + id: sha + run: | + cd imagestreams/ + git clone https://github.com/sclorg/ci-scripts.git ci-scripts + sudo apt -y update && sudo apt install -y python3-yaml + sha=$(git rev-parse HEAD) + echo "sha=$sha" >> "$GITHUB_OUTPUT" + + - name: Check imagestream files + id: check + shell: bash + run: | + result="success" + python ci-scripts/ocp-stream-generator/ocp-stream-generator/stream_generator.py imagestreams.yaml + git diff --exit-code -- imagestreams || result="failure" + echo "result=$result" >> "$GITHUB_OUTPUT" + + - name: Set final commit status + uses: myrotvorets/set-commit-status-action@v2.0.0 + with: + status: ${{ steps.check.outputs.result }} + context: "Imagestream files check" + sha: ${{ steps.sha.outputs.sha }} + + - name: Exit on ERR + shell: bash + run: | + _result=${{ steps.check.outputs.result }} + if [ "$_result" == failure ]; then + git show -s -- imagestreams + echo "::error::Imagestream files are not regenerated properly." + echo "::warning::Please use 'sclorg/ci-scripts/ocp-stream-generator'" + echo "::warning::to regenerate them." + exit 1 + fi +...