QuestionQ9

Author and manage workflows

As a developer, you are creating a workflow that deploys to both DevCloud and TestCloud resources. Each cloud resource is accessed using a different deployment key. Which approach best enables you to use the same reusable workflow in separate jobs while targeting the different cloud resources?

  • A Populate a DEPLOY_KEY repository secret with a JSON object containing DevCloud and TestCloud properties. Then specify DEPLOY_KEY.DevCloud in the secrets sections of the reusable workflow.
  • B Use a marketplace action to conditionally parse the DEPLOY_KEY repository secret based on the cloud resource name.
  • C Store the different keys in a DEPLOY_KEY environment secret in the DevCloud and TestCloud environments. Specify DEPLOY_KEY in the secrets section of the reusable workflow.
  • D Create repository secrets named DevCloud.DEPLOY_KEY and TestCloud.DEPLOY_KEY so that the reusable workflow parses the secrets by resource name.
Explanation

GitHub Actions environments can scope secrets independently, so DevCloud and TestCloud can each provide a different DEPLOY_KEY value under the same secret name. A reusable workflow can consistently reference DEPLOY_KEY while the deployment job uses the appropriate environment. Reusable workflows support defining and using secrets, and an environment specified on a job in the reusable workflow supplies that environment’s secret value.

Learn more

Community Discussion

No comments yet. Be the first to start the discussion!