From ecb16b441341dc7454e672b849d4744b3a77b977 Mon Sep 17 00:00:00 2001 From: Bojan Rajh Date: Tue, 7 Nov 2023 16:08:07 +0100 Subject: [PATCH] feat: cleanup workflows and scripts --- .github/scripts/trigger-workflow.cjs | 29 -------------- .github/workflows/external-healthcheck.yml | 32 +++++++-------- .github/workflows/update-healthcheck.yml | 45 ++++++++++++++++++++++ 3 files changed, 58 insertions(+), 48 deletions(-) delete mode 100644 .github/scripts/trigger-workflow.cjs create mode 100644 .github/workflows/update-healthcheck.yml diff --git a/.github/scripts/trigger-workflow.cjs b/.github/scripts/trigger-workflow.cjs deleted file mode 100644 index 426e8a8f..00000000 --- a/.github/scripts/trigger-workflow.cjs +++ /dev/null @@ -1,29 +0,0 @@ -const { Octokit } = require("@octokit/rest"); - -const octokit = new Octokit({ - auth: process.env.PERSONAL_ACCESS_TOKEN, -}); - -async function triggerWorkflow() { - try { - const response = await octokit.rest.actions.createWorkflowDispatch({ - owner: 'shopware', - repo: 'docs', - ref: `main`, - workflow_id: 'update-healthcheck.yml', - inputs: { - branch: process.env.DEV_HUB_BRANCH, - repo: process.env.DEV_HUB_REPO, - sha: process.env.DEV_HUB_SHA, - check: process.env.DEV_HUB_CHECK, - conclusion: process.env.DEV_HUB_CONCLUSION, - }, - }); - - console.log("Workflow triggered successfully:", response.data); - } catch (error) { - console.error("Error triggering workflow:", error.message, error); - } -} - -triggerWorkflow(); \ No newline at end of file diff --git a/.github/workflows/external-healthcheck.yml b/.github/workflows/external-healthcheck.yml index b6c885c4..3bdacf18 100644 --- a/.github/workflows/external-healthcheck.yml +++ b/.github/workflows/external-healthcheck.yml @@ -125,25 +125,19 @@ jobs: - trigger-build if: ${{ always() }} steps: - - name: Checkout Repository - uses: actions/checkout@v2 - - name: Prepare - uses: ./.github/actions/checkout-install + - uses: octokit/request-action@v2.x + name: Update check with: - apt: true - - - name: Install dependencies - run: | - pnpm i @octokit/rest - - - name: Update Check - run: | - node .github/scripts/trigger-workflow.cjs + route: POST /repos/{owner}/{repo}/actions/workflows/{workflow_id}/dispatches + owner: ${{ inputs.owner }} + repo: ${{ inputs.repo }} + ref: main + workflow_id: update-healthcheck.yml + inputs: | + owner: ${{ inputs.owner }} + repo: ${{ inputs.repo }} + check: "${{ fromJson(steps.create_check_run.outputs.data).id }}" + conclusion: ${{ steps.status.outputs.success == 'true' && 'success' || 'failure' }} env: - PERSONAL_ACCESS_TOKEN: ${{ secrets.DEV_HUB_PERSONAL_ACCESS_TOKEN }} - DEV_HUB_BRANCH: ${{ inputs.branch }} - DEV_HUB_REPO: ${{ inputs.repo }} - DEV_HUB_SHA: ${{ inputs.sha }} - DEV_HUB_CHECK: ${{ inputs.check }} - DEV_HUB_CONCLUSION: ${{ steps.status.outputs.success == 'true' && 'success' || 'failure' }} \ No newline at end of file + GITHUB_TOKEN: ${{ secrets.DEV_HUB_PERSONAL_ACCESS_TOKEN }} diff --git a/.github/workflows/update-healthcheck.yml b/.github/workflows/update-healthcheck.yml new file mode 100644 index 00000000..0ac958d5 --- /dev/null +++ b/.github/workflows/update-healthcheck.yml @@ -0,0 +1,45 @@ +# this action is used by sub-repos +on: + workflow_call: + inputs: + owner: + description: "Owner to checkout" + required: true + type: string + repo: + description: "Repo to checkout" + required: true + type: string + check: + description: "Check ID" + required: true + type: string + conclusion: + description: "Healthcheck conclusion" + required: true + type: string + secrets: + TOKEN: + required: true + +jobs: + + trigger-healthckeck: + runs-on: ubuntu-latest + steps: + + - uses: octokit/request-action@v2.x + name: Update check run + with: + route: PATCH /repos/{owner}/{repo}/check-runs/{check_run_id} + owner: ${{ inputs.owner }} + repo: ${{ inputs.repo }} + check_run_id: ${{ inputs.check }} + name: DevHub + status: completed + conclusion: ${{ inputs.conclusion }} + output: | + title: Developer Portal healthcheck + summary: Building the project in DevHub (Developer Portal) + env: + GITHUB_TOKEN: ${{ secrets.TOKEN }}