Challenge your understanding of workflow automation and configuration with this quiz on common interview questions about GitHub Actions. Enhance your knowledge of best practices, syntax, and key features used in continuous integration and deployment workflows.
Which event will trigger a workflow run when a pull request is opened against the 'main' branch of a repository?
Explanation: The 'pull_request' event is used to trigger workflows when pull requests are opened, synchronized, or closed. 'push_request' and 'request_pull' may sound plausible but are not valid event names in workflow configuration. 'pr_opened' is a common typo or misremembered event name. Using the correct event ensures your workflows respond to the intended triggers.
What is the correct top-level key to declare the entry point for a workflow job in a YAML workflow file?
Explanation: 'jobs' is the required top-level key that defines the sequence of jobs a workflow will run. 'steps' is defined under 'jobs' to specify individual tasks. 'actions' and 'tasks' are not valid top-level keys; 'actions' refers to reusable commands, and 'tasks' is not recognized in workflow syntax. Knowing the structure prevents configuration errors.
How should you reference a stored secret, such as an API token, securely within a workflow step?
Explanation: The correct and secure way to reference a secret in a workflow step is '${{ secrets.API_TOKEN }}'. '${ secrets.API_TOKEN }' has incorrect syntax due to missing curly braces. '${{ api_token }}' and '${{ variables.API_TOKEN }}' do not point to the secure secrets store and will not retrieve sensitive information safely. Using the right syntax maintains security and access control in workflows.
Which method can you use to pass build output files from one job to another in a multi-job workflow?
Explanation: To share build outputs between jobs, you must upload artifacts in one job and download them in another. Copy and paste methods are manual and not applicable in automated workflows. Directly accessing another job's workspace is not possible due to sandboxed environments. While the steps context provides access within a job, it does not facilitate sharing between jobs.
What is the correct way to call a reusable workflow from another workflow file?
Explanation: To invoke a reusable workflow, use the 'uses' keyword followed by the path to the workflow file. The 'include' keyword does not exist in workflow syntax. There is no 'imports' section available for workflows, and 'subworkflows' is not a recognized configuration. Using the correct approach ensures modular and maintainable automation.