diff --git a/.github/scripts/trigger-workflow.js b/.github/scripts/trigger-workflow.js new file mode 100644 index 00000000..7bd10f92 --- /dev/null +++ b/.github/scripts/trigger-workflow.js @@ -0,0 +1,28 @@ +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, + }, + }); + + 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/scripts/update-check.cjs b/.github/scripts/update-check.cjs deleted file mode 100644 index da02d959..00000000 --- a/.github/scripts/update-check.cjs +++ /dev/null @@ -1,27 +0,0 @@ -const { Octokit } = require('@octokit/rest'); - -const octokit = new Octokit({ - auth: process.env.PERSONAL_ACCESS_TOKEN, - //auth: process.env.GITHUB_TOKEN, - //auth: process.env.ADDITIONAL_ACCESS_TOKEN, -}); - -async function createCheck() { - const response = await octokit.checks.update({ - owner: process.env.DEV_HUB_REPO.split('/')[0], - repo: process.env.DEV_HUB_REPO.split('/')[1], - check_run_id: process.env.DEV_HUB_CHECK, - name: 'DevHub', - status: 'completed', - conclusion: 'success', - completed_at: new Date().toISOString(), - output: { - title: 'Developer Portal healthcheck', - summary: 'Building the project in DevHub (Developer Portal)', - }, - }); - - console.log('Check updated:', response.data); -} - -createCheck(); \ No newline at end of file diff --git a/.github/workflows/external-healthcheck.yml b/.github/workflows/external-healthcheck.yml index 71540a54..a6f0dbec 100644 --- a/.github/workflows/external-healthcheck.yml +++ b/.github/workflows/external-healthcheck.yml @@ -1,11 +1,6 @@ name: External healthcheck on: - #workflow_run: - # workflows: - # - "Healthcheck" - # types: - # - completed workflow_dispatch: inputs: branch: @@ -24,10 +19,6 @@ on: description: "Check ID" required: true type: string - token: - description: "Token used in createCheck" - required: true - type: string jobs: @@ -51,123 +42,92 @@ jobs: - name: Update Check run: | - node .github/scripts/update-check.cjs - exit 1 + node .github/scripts/trigger-workflow.js env: - GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} PERSONAL_ACCESS_TOKEN: ${{ secrets.DEV_HUB_PERSONAL_ACCESS_TOKEN }} - ADDITIONAL_ACCESS_TOKEN: ${{ inputs.token }} DEV_HUB_BRANCH: ${{ inputs.branch }} DEV_HUB_REPO: ${{ inputs.repo }} + DEV_HUB_SHA: ${{ inputs.sha }} DEV_HUB_CHECK: ${{ inputs.check }} - trigger-build: - runs-on: ubuntu-latest - needs: - - update-check-run - - steps: - - name: Checkout repository - uses: actions/checkout@v3 +# trigger-build: +# runs-on: ubuntu-latest +# needs: +# - update-check-run - - name: Print inputs - run: | - echo "branch" ${{ inputs.branch }} - echo "repo" ${{ inputs.repo }} - echo "sha" ${{ inputs.sha }} +# steps: +# - name: Checkout repository +# uses: actions/checkout@v3 + +# - name: Print inputs +# run: | +# echo "branch" ${{ inputs.branch }} +# echo "repo" ${{ inputs.repo }} +# echo "sha" ${{ inputs.sha }} - ORG=$(dirname ${{ inputs.repo }}) - BRANCH=${{ inputs.branch }} +# ORG=$(dirname ${{ inputs.repo }}) +# BRANCH=${{ inputs.branch }} - if [[ "${{ inputs.repo }}" == *"/frontends" ]]; then - echo "Embedding frontends" - sed -i "0,/ORG_FRONTENDS.*/s/.*ORG_FRONTENDS.*/ORG_FRONTENDS=$ORG/" ./.github/scripts/embed.sh - sed -i "0,/BRANCH_FRONTENDS.*/s/.*BRANCH_FRONTENDS.*/BRANCH_FRONTENDS=$BRANCH/" ./.github/scripts/embed.sh +# if [[ "${{ inputs.repo }}" == *"/frontends" ]]; then +# echo "Embedding frontends" +# sed -i "0,/ORG_FRONTENDS.*/s/.*ORG_FRONTENDS.*/ORG_FRONTENDS=$ORG/" ./.github/scripts/embed.sh +# sed -i "0,/BRANCH_FRONTENDS.*/s/.*BRANCH_FRONTENDS.*/BRANCH_FRONTENDS=$BRANCH/" ./.github/scripts/embed.sh - elif [[ "${{ inputs.repo }}" == *"/admin-extension-sdk" ]]; then - echo "Embedding admin-extension-sdk" - sed -i "0,/ORG_ADMIN_EXTENSION_SDK.*/s/.*ORG_ADMIN_EXTENSION_SDK.*/ORG_ADMIN_EXTENSION_SDK=$ORG/" ./.github/scripts/embed.sh - sed -i "0,/BRANCH_ADMIN_EXTENSION_SDK.*/s/.*BRANCH_ADMIN_EXTENSION_SDK.*/BRANCH_ADMIN_EXTENSION_SDK=$BRANCH/" ./.github/scripts/embed.sh +# elif [[ "${{ inputs.repo }}" == *"/admin-extension-sdk" ]]; then +# echo "Embedding admin-extension-sdk" +# sed -i "0,/ORG_ADMIN_EXTENSION_SDK.*/s/.*ORG_ADMIN_EXTENSION_SDK.*/ORG_ADMIN_EXTENSION_SDK=$ORG/" ./.github/scripts/embed.sh +# sed -i "0,/BRANCH_ADMIN_EXTENSION_SDK.*/s/.*BRANCH_ADMIN_EXTENSION_SDK.*/BRANCH_ADMIN_EXTENSION_SDK=$BRANCH/" ./.github/scripts/embed.sh - elif [[ "${{ inputs.repo }}" == *"/meteor-icon-kit" ]]; then - echo "Embedding meteor-icon-kit" - sed -i "0,/ORG_METEOR_ICON_KIT.*/s/.*ORG_METEOR_ICON_KIT.*/ORG_METEOR_ICON_KIT=$ORG/" ./.github/scripts/embed.sh - sed -i "0,/BRANCH_METEOR_ICON_KIT.*/s/.*BRANCH_METEOR_ICON_KIT.*/BRANCH_METEOR_ICON_KIT=$BRANCH/" ./.github/scripts/embed.sh +# elif [[ "${{ inputs.repo }}" == *"/meteor-icon-kit" ]]; then +# echo "Embedding meteor-icon-kit" +# sed -i "0,/ORG_METEOR_ICON_KIT.*/s/.*ORG_METEOR_ICON_KIT.*/ORG_METEOR_ICON_KIT=$ORG/" ./.github/scripts/embed.sh +# sed -i "0,/BRANCH_METEOR_ICON_KIT.*/s/.*BRANCH_METEOR_ICON_KIT.*/BRANCH_METEOR_ICON_KIT=$BRANCH/" ./.github/scripts/embed.sh - elif [[ "${{ inputs.repo }}" == *"/meteor-component-library" ]]; then - echo "Embedding meteor-component-library" - sed -i "0,/ORG_METEOR_COMPONENT_LIBRARY.*/s/.*ORG_METEOR_COMPONENT_LIBRARY.*/ORG_METEOR_COMPONENT_LIBRARY=$ORG/" ./.github/scripts/embed.sh - sed -i "0,/BRANCH_METEOR_COMPONENT_LIBRARY.*/s/.*BRANCH_METEOR_COMPONENT_LIBRARY.*/BRANCH_METEOR_COMPONENT_LIBRARY=$BRANCH/" ./.github/scripts/embed.sh +# elif [[ "${{ inputs.repo }}" == *"/meteor-component-library" ]]; then +# echo "Embedding meteor-component-library" +# sed -i "0,/ORG_METEOR_COMPONENT_LIBRARY.*/s/.*ORG_METEOR_COMPONENT_LIBRARY.*/ORG_METEOR_COMPONENT_LIBRARY=$ORG/" ./.github/scripts/embed.sh +# sed -i "0,/BRANCH_METEOR_COMPONENT_LIBRARY.*/s/.*BRANCH_METEOR_COMPONENT_LIBRARY.*/BRANCH_METEOR_COMPONENT_LIBRARY=$BRANCH/" ./.github/scripts/embed.sh - elif [[ "${{ inputs.repo }}" == *"/docs" ]]; then - echo "Embedding docs" - sed -i "0,/ORG_DOCS.*/s/.*ORG_DOCS.*/ORG_DOCS=$ORG/" ./.github/scripts/embed.sh - sed -i "0,/BRANCH_DOCS.*/s/.*BRANCH_DOCS.*/BRANCH_DOCS=$BRANCH/" ./.github/scripts/embed.sh +# elif [[ "${{ inputs.repo }}" == *"/docs" ]]; then +# echo "Embedding docs" +# sed -i "0,/ORG_DOCS.*/s/.*ORG_DOCS.*/ORG_DOCS=$ORG/" ./.github/scripts/embed.sh +# sed -i "0,/BRANCH_DOCS.*/s/.*BRANCH_DOCS.*/BRANCH_DOCS=$BRANCH/" ./.github/scripts/embed.sh - else - echo "Unknown repository ${{inputs.repo}}" - echo "Branch ${{inputs.branch}}" - exit 1 - fi +# else +# echo "Unknown repository ${{inputs.repo}}" +# echo "Branch ${{inputs.branch}}" +# exit 1 +# fi - cat ./.github/scripts/embed.sh - - - name: Prepare - uses: ./.github/actions/checkout-install - with: - apt: true - - - name: Embed repos - env: - GITLAB_FRONTENDS_USERNAME: ${{ secrets.GITLAB_FRONTENDS_USERNAME }} - GITLAB_FRONTENDS_ACCESS_KEY: ${{ secrets.GITLAB_FRONTENDS_ACCESS_KEY }} - FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} - FIGMA_FILE: ${{ secrets.FIGMA_FILE }} - run: | - chmod +x ./.github/scripts/embed.sh - .github/scripts/embed.sh - - - name: Test dev - run: | - export NODE_OPTIONS="--max-old-space-size=8096" - pnpm run test - - - name: Build - run: | - export NODE_OPTIONS="--max-old-space-size=8096" - export USERCENTRICS="65ynhGFvE" - pnpm run build - - - name: Test build - run: | - export NODE_OPTIONS="--max-old-space-size=8096" - pnpm run test:build - -# vars: -# runs-on: ubuntu-latest -# outputs: -# DEV_HUB_REPO: ${{ secrets.DEV_HUB_REPO }} -# DEV_HUB_BRANCH: ${{ secrets.DEV_HUB_BRANCH }} -# steps: -# - run: echo "Exposing env vars" +# cat ./.github/scripts/embed.sh -# update-status: -# runs-on: ubuntu-latest - -# steps: -# - name: Check outcome -# id: outcome -# run: echo "::set-output name=outcome::${{ toJson(needs.workflow_run.conclusion == 'success') }}" +# - name: Prepare +# uses: ./.github/actions/checkout-install +# with: +# apt: true -# - name: Update Workflow Status -# uses: octokit/request-action@v2.x -# with: -# route: POST /repos/:owner/:repo/check-runs/:check_run_id -# owner: shopware -# repo: docs -# check_run_id: ${{ github.event.workflow_run.id }} -# name: Your Check Name -# status: ${{ steps.outcome.outputs.outcome == 'true' && 'completed' || 'completed' }} -# conclusion: ${{ steps.outcome.outputs.outcome == 'true' && 'success' || 'failure' }} +# - name: Embed repos # env: -# GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }} \ No newline at end of file +# GITLAB_FRONTENDS_USERNAME: ${{ secrets.GITLAB_FRONTENDS_USERNAME }} +# GITLAB_FRONTENDS_ACCESS_KEY: ${{ secrets.GITLAB_FRONTENDS_ACCESS_KEY }} +# FIGMA_TOKEN: ${{ secrets.FIGMA_TOKEN }} +# FIGMA_FILE: ${{ secrets.FIGMA_FILE }} +# run: | +# chmod +x ./.github/scripts/embed.sh +# .github/scripts/embed.sh + +# - name: Test dev +# run: | +# export NODE_OPTIONS="--max-old-space-size=8096" +# pnpm run test + +# - name: Build +# run: | +# export NODE_OPTIONS="--max-old-space-size=8096" +# export USERCENTRICS="65ynhGFvE" +# pnpm run build + +# - name: Test build +# run: | +# export NODE_OPTIONS="--max-old-space-size=8096" +# pnpm run test:build \ No newline at end of file