Bosch IoT Insights

Deploying your first widget

Proceed as follows:

  1. Navigate to the .github/workflows directory of your target repository. If you did not copy it earlier from the demo repository, you can copy it now or just create it.
    Keep in mind that the .github/workflows directory must always be at the root level of the repository. If you use a different directory name or structure, the action will fail.

    images/confluence/download/attachments/5169563894/workflows_folder-version-1-modificationdate-1736761723000-api-v2.png
  2. In the .github/workflows directory, you should have a deploy.yml file with the content from the example below, adjusted to your needs.
    You can either copy the available file from the demo repository or create a new one.

GitHub Action for the deploy operation

For details about GitHub Actions, read the GitHub Docs.

Below is an example of a GitHub Action that deploys the custom widget to the project management service.

# Simple workflow for deploying static content to GitHub Pages
name: Deploy to Project Management Service
 
on:
# Runs when the Build workflow on the main branch has run
workflow_run:
workflows: [ Build ]
branches: [ main ]
types:
- completed
 
# Sets permissions of the GITHUB_TOKEN to allow loading of action artifacts and deploy to project management service
permissions:
contents: read
id-token: write
actions: read
security-events: write
 
jobs:
deploy-my-custom-widget:
uses: bosch-insights-customers/workflows/.github/workflows/deployer.yml@main
secrets:
token: ${{ secrets.GITHUB_TOKEN }}

Explanation

Here is an explanation of what happens through this action.

  1. The action is configured to trigger when the build job is completed successfully on the main branch. Note that the line "workflows: [ Build ]" refers to the name used in the build.yml file. The name must match.

  2. Explicit permissions are set to ensure that the workflow can read the build artifacts and can make an external request to upload the artifacts to project management service.

  3. Please note that modifying the permissions will fail the build in one way or the other. Hence, please ensure the permissions are set as shown in the above example.

  4. A job is configured which uses the bosch-insights-customers/workflows/.github/workflows/deployer.yml@main workflow provided by us.

    1. This workflow understands the results of the npm_package_builder.yml workflow. Hence no need to explicitly set working directory or widget name.

    2. This workflow uses the widget name from insights-manifest.json and uploads the artifacts to the project management endpoint.