diff --git a/.github/workflows/external_triggered_CI.yml b/.github/workflows/external_triggered_CI.yml new file mode 100644 index 0000000000..1e46de4f3d --- /dev/null +++ b/.github/workflows/external_triggered_CI.yml @@ -0,0 +1,121 @@ +on: + repository_dispatch: + types: [CI_trigger_type] + +env: + EVENT_NUMBER: ${{ github.event.client_payload.number }} + BASE_SHA: ${{ github.event.client_payload.base_sha }} + PR_SHA: ${{ github.event.client_payload.head_sha }} + REPO_NAME: ${{ github.event.client_payload.github_repo }} + #WORKSPACE: ${{ github.workspace }} + PR_SERVER: ${{ vars.LTX_PR_SERVER }} + # WORKSPACE: $GITHUB_WORKSPACE + +permissions: + contents: read + +jobs: + run_dymola: + runs-on: ubuntu-latest + permissions: {} + container: + image: ghcr.io/matthiasbschaefer/dymola_image:latest + options: --user=resimuser --rm + credentials: + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 + repository: ${{ env.REPO_NAME }} + + - name: prepare + run: /work/run_scripts/prepare_tool.sh $GITHUB_WORKSPACE $EVENT_NUMBER $BASE_SHA $PR_SHA dymola + + - name: run + run: /work/run_scripts/run_tool.sh $GITHUB_WORKSPACE $EVENT_NUMBER $BASE_SHA dymola + + + + run_openmodelica: + runs-on: ubuntu-latest + permissions: {} + container: + image: ghcr.io/matthiasbschaefer/om_image:latest + options: --user=resimuser --rm + credentials: + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + + steps: + - uses: actions/checkout@v6 + with: + persist-credentials: false + fetch-depth: 0 + repository: ${{ env.REPO_NAME }} + + - name: prepare + run: /work/run_scripts/prepare_tool.sh $GITHUB_WORKSPACE $EVENT_NUMBER $BASE_SHA $PR_SHA om + + - name: run + run: /work/run_scripts/run_tool.sh $GITHUB_WORKSPACE $EVENT_NUMBER $BASE_SHA om + + + + overview: + runs-on: ubuntu-latest + permissions: {} + needs: [run_openmodelica, run_dymola] + if: always() + container: + image: ghcr.io/matthiasbschaefer/om_image:latest + options: --user=resimuser --rm + credentials: + username: ${{ secrets.GHCR_USER }} + password: ${{ secrets.GHCR_TOKEN }} + + + steps: + - name: create_overview + run: /work/run_scripts/create_overview.sh $EVENT_NUMBER + - name: publish + run: /work/run_scripts/publish_reports.sh $EVENT_NUMBER + + + + review: + runs-on: ubuntu-latest + needs: [run_openmodelica, run_dymola, overview] + if: always() + permissions: {} + # pull-requests: write + steps: + - name: Decide review event + id: decide + run: | + if [ "${{ needs.run_openmodelica.result }}" = "success" ] && [ "${{ needs.run_dymola.result }}" = "success" ]; then + echo "event=APPROVE" >> "$GITHUB_OUTPUT" + else + echo "event=REQUEST_CHANGES" >> "$GITHUB_OUTPUT" + fi + - name: Create review in other repo + env: + GH_TOKEN: ${{ secrets.MODELICA_TOKEN }} + TARGET_REPO: ${{ env.REPO_NAME }} + TARGET_PR: ${{ env.EVENT_NUMBER }} + EVENT: ${{ steps.decide.outputs.event }} + BODY: "Please look here for details:${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/Modelica/PR_comparison_report.html and ${{ env.PR_SERVER }}/${{ env.EVENT_NUMBER }}/ModelicaTest/PR_comparison_report.html" + + run: | + set -euo pipefail + API="https://api.github.com/repos/${TARGET_REPO}/pulls/${TARGET_PR}/reviews" + payload="$(jq -n --arg event "$EVENT" --arg body "$BODY" '{event: $event, body: $body}')" + curl --fail-with-body -sS -X POST "$API" \ + -H "Authorization: Bearer $GH_TOKEN" \ + -H "Accept: application/vnd.github+json" \ + -H "Content-Type: application/json" \ + -H "X-GitHub-Api-Version: 2022-11-28" \ + --data "$payload" \ No newline at end of file