Proceed as follows:
- 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. - 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. It covers the deployments of both the main branch and the feature branch. Keep in mind that:
- It is not mandatory to configure both.
- The event
feature-branch-deploywill trigger the deployment only if the feature branch build is enabled in the build workflow.
deploy.yml
# Simple workflow for deploying static content to GitHub Pagesname: Deploy to Project Management Serviceon: repository_dispatch: types: [ feature-branch-deploy, main-deploy ]# Sets permissions of the GITHUB_TOKEN to allow loading of action artifacts and deploy to project management servicepermissions: contents: read id-token: write actions: read security-events: writejobs: 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.
- The action is configured to trigger when the
buildjob is completed successfully on themainbranch. Note that the line"workflows: [ Build ]"refers to the name used in the build.yml file. The name must match. - 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.
- 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.
- A job is configured which uses the bosch-insights-customers/workflows/.github/workflows/deployer.yml@main workflow provided by us.
- This workflow understands the results of the npm_package_builder.yml workflow. Hence no need to explicitly set working directory or widget name.
- This workflow uses the widget name from insights-manifest.json and uploads the artifacts to the project management endpoint.
