Assess your understanding of GitHub Actions basics, including workflow configuration, triggers, and core concepts essential for automating development tasks in repositories. Perfect for individuals seeking to validate their foundational knowledge on automation and continuous integration using workflows.
Where should the main workflow configuration file be placed within a repository to use automated workflows?
Explanation: The main configuration file for workflows must be stored inside the .github/workflows directory of a repository, as this is where workflow files are automatically recognized. Storing it in the root directory or a folder named runs will not trigger the workflow system. Placing it within the README file is invalid, as markdown files cannot contain workflow configurations.
What format is typically used to write workflow configuration files for automation tasks?
Explanation: Workflow configuration files are generally written in YAML, which is both human-readable and suitable for configuration purposes. JSON and XML are not the standard formats for configuring workflows, and CSV is used for lists or tables, not workflow automation. YAML's syntax and structure are specifically supported for defining these workflows.
Which key is used in a workflow file to specify events that start the workflow, such as 'push' or 'pull_request'?
Explanation: The 'on' key is used in configuration files to specify events like 'push' or 'pull_request' that initiate the workflow. Using 'runs' or 'event' as the top-level key will not correctly define the trigger, and 'trigger' is not a recognized keyword for this purpose. Therefore, 'on' is the proper way to declare workflow triggers.
In the context of workflow configuration, what is the role of a 'job'?
Explanation: A 'job' is designed to group steps together and execute them in a given environment, such as a virtual machine or container. Sending notifications, creating backups, or log analysis are not the main functions of a job. Instead, these may be specific steps within a job, not the definition of the job itself.
When you want to reuse predefined automation logic within a workflow, which keyword is used to include an action?
Explanation: The 'uses' keyword is intended for referencing and reusing predefined actions in a workflow, allowing integration of external or reusable logic. The 'run' keyword is meant for executing shell commands, while 'exec' and 'implement' are not valid workflow keywords in this context. Therefore, 'uses' is the correct choice when including an action.
Which key should you use to declare the operating system environment for a job in a workflow file?
Explanation: 'runs-on' is the recognized field for specifying the operating system, such as ubuntu-latest or windows-latest, that a job should use. Neither 'env-os' nor 'os-type' are valid keywords in this context, and 'environment' is for different configuration purposes. 'runs-on' establishes the correct environment for the job to execute.
What is the recommended way to safely use confidential data like API keys in workflow files?
Explanation: Storing sensitive data as secrets and referencing them through the secrets context prevents exposure within workflow files. Hardcoding credentials, storing them in plain environment files, or sending them directly in scripts pose security risks. Using secrets is the safest and recommended approach.
If a step in one job fails, what is the typical default effect on subsequent steps in that job?
Explanation: By default, if a step fails in a job, the remaining steps in that job are skipped and the job is marked as failed. The workflow file itself is not deleted, and not all workflows stop running forever. There are ways to override this behavior, but continuing steps after a failure is not the standard.
What is the primary purpose of uploading artifacts at the end of a job?
Explanation: Artifacts are meant to temporarily store files created during a workflow, making them available for later download or use in other jobs. They do not affect badge colors, are not responsible for displaying code coverage specifically, and do not delete logs by default. Storing build or test results is the main purpose of artifacts.
Which workflow trigger allows a workflow to be started manually by a user from the web interface?
Explanation: 'workflow_dispatch' is the event used to set up manual triggers so users can start workflows from the web interface. 'Push' triggers on code uploads, 'schedule' is used for automatic timing, and 'fork' is not a recognized trigger event for manual execution. Only 'workflow_dispatch' provides this manual control.