


















































































Study with the several resources on Docsity
Earn points by helping other students or get them with a premium plan
This page cannot be seen from the preview
Don't miss anything!



















































































Question 1. Which GitHub Actions trigger runs a workflow on a fixed schedule? A) push B) workflow_dispatch C) schedule D) pull_request Answer: C Explanation: The schedule event uses cron syntax to run workflows at defined times. Question 2. In a workflow_dispatch trigger, how can you collect user input? A) By reading environment variables B) Using the inputs keyword with type and description fields C) Through a separate webhook call D) By parsing the repository README file Answer: B Explanation: workflow_dispatch supports an inputs map where each input can have a type, description, and default value. Question 3. Which of the following webhook activity types is not a valid value for the pull_request trigger? A) opened B) reopened C) synchronize D) merged Answer: D Explanation: merged is not an activity type; merging a PR triggers the closed activity with merged: true.
Question 4. How would you configure a workflow to run only when changes are made to files in the docs/ directory? A) paths: - 'docs/**' B) branches: - docs/* C) tags: - docs D) ignore: - 'docs/**' Answer: A Explanation: The paths filter limits runs to commits that modify files matching the pattern. Question 5. Which syntax correctly excludes a job from running on the main branch? A) if: github.ref != 'refs/heads/main' B) if: github.branch != 'main' C) if: ${{ !contains(github.ref, 'main') }} D) if: github.event_name != 'push' Answer: A Explanation: github.ref holds the full ref name; comparing it to refs/heads/main excludes the main branch. Question 6. In a reusable workflow, how do you expose an input to the caller? A) Define it under on.workflow_call.inputs B) Place it in the env block of the workflow file C) Use outputs in the steps section D) Declare it in the repository settings Answer: A
Answer: A Explanation: github.event_name contains the name of the event (e.g., push, release). Question 10. How can you make a step run only when a previous step fails? A) if: failure() B) if: always() C) if: success() D) if: cancelled() Answer: A Explanation: The failure() function returns true when any previous step in the same job has failed. Question 11. Which of the following is the correct way to reference an output named artifact-path from a previous job called build? A) ${{ steps.build.outputs.artifact-path }} B) ${{ needs.build.outputs.artifact-path }} C) ${{ jobs.build.outputs.artifact-path }} D) ${{ env.artifact-path }} Answer: B Explanation: needs..outputs provides outputs from jobs that have completed successfully. Question 12. In a job, how do you declare that it must wait for the test job to finish before starting? A) needs: test B) depends_on: test C) run-after: test
D) order: test Answer: A Explanation: The needs keyword creates a dependency on the specified job(s). Question 13. Which of the following is not a valid service container definition key? A) image B) ports C) health-check D) environment Answer: C Explanation: The correct key is healthcheck, not health-check. Question 14. How would you expose port 5432 of a PostgreSQL service container to the job steps? A) ports: - 5432 B) ports: - 5432:5432 C) expose: - 5432 D) network: - 5432 Answer: B Explanation: ports uses the host:container syntax; 5432:5432 maps the container’s port to the same host port. Question 15. Which strategy key allows you to limit the number of matrix jobs that run concurrently? A) max-parallel B) concurrency
B) actions/cache with key: ${{ runner.os }}-npm-${{ hashFiles('package- lock.json') }} C) actions/upload-artifact D) actions/download-artifact Answer: B Explanation: actions/cache stores files based on a cache key; the example key hashes package-lock.json to detect changes. Question 19. How can a job write a variable that will be available to subsequent jobs? A) echo "VAR=value" >> $GITHUB_ENV B) echo "::set-output name=VAR::value" C) echo "VAR=value" >> $GITHUB_OUTPUT D) echo "::set-env name=VAR::value" Answer: A Explanation: Writing to $GITHUB_ENV creates an environment variable for downstream jobs. Question 20. Which command uploads a build artifact called dist.zip to the workflow run? A) actions/upload-artifact@v3 with with: name: dist path: dist.zip B) actions/download-artifact@v3 with with: name: dist path: dist.zip C) actions/cache@v3 with key: dist D) actions/artifact@v2 with upload: dist.zip Answer: A Explanation: actions/upload-artifact uploads files; name is the artifact name, path is the file location.
Question 21. Which of the following statements about reusable workflows is true? A) They cannot accept secrets from the caller. B) They must be stored in the same repository as the caller. C) They are invoked using the uses keyword inside a job. D) They cannot contain matrix strategies. Answer: C Explanation: A reusable workflow is called with uses: owner/repo/.github/workflows/workflow.yml@ref. Question 22. How would you reference the output url from a step named deploy within the same job? A) ${{ steps.deploy.outputs.url }} B) ${{ jobs.deploy.outputs.url }} C) ${{ env.deploy.url }} D) ${{ needs.deploy.outputs.url }} Answer: A Explanation: Step outputs are accessed via steps..outputs.. Question 23. Which of the following is the correct syntax to enable step-debug logging for a workflow run? A) Set repository secret ACTIONS_STEP_DEBUG to true. B) Add debug: true under jobs..steps. C) Use run: echo "::debug::message" in every step. D) Set GITHUB_DEBUG environment variable to 1. Answer: A
B) echo "# Title" >> $GITHUB_OUTPUT C) echo "# Title" >> $GITHUB_ENV D) echo "# Title" >> $GITHUB_WORKSPACE Answer: A Explanation: Writing to $GITHUB_STEP_SUMMARY appends content that appears in the “Summary” tab of the run. Question 27. Which REST API endpoint lists all artifacts for a repository? A) GET /repos/{owner}/{repo}/actions/artifacts B) GET /repos/{owner}/{repo}/artifacts C) GET /actions/artifacts/{owner}/{repo} D) GET /repositories/{owner}/{repo}/actions/artifacts Answer: A Explanation: The GitHub REST API provides /repos/{owner}/{repo}/actions/artifacts to list artifacts. Question 28. When creating a private action for an organization, which visibility option must be set? A) public B) internal C) private D) restricted Answer: B Explanation: internal actions are visible to all repositories within the same organization but not to the public marketplace. Question 29. Which file defines the inputs, outputs, and runtime for a JavaScript action?
A) Dockerfile B) action.yml C) package.json D) main.js Answer: B Explanation: action.yml (or action.yaml) contains the metadata for any action type. Question 30. What is the default permission scope of the automatically generated GITHUB_TOKEN? A) read:all only B) write:all only C) read for contents and write for pull requests, issues, and actions D) Full admin rights to the repository Answer: C Explanation: By default, GITHUB_TOKEN can read repository contents and write to issues, PRs, and actions, but cannot delete or modify protected branches. Question 31. Which of the following is a recommended practice for versioning a reusable workflow? A) Use a mutable tag like latest. B) Pin the workflow to a commit SHA. C) Reference the workflow without a version. D) Use a date-based tag only. Answer: B Explanation: Pinning to a SHA ensures the caller always runs the exact version intended, avoiding accidental changes.
Explanation: environment ties the job to a GitHub environment, enabling protection rules and secrets scoped to that environment. Question 35. Which of the following statements about OIDC in GitHub Actions is correct? A) OIDC allows the workflow to obtain short-lived JWTs for cloud provider authentication without storing long-lived secrets. B) OIDC replaces the need for GITHUB_TOKEN. C) OIDC can only be used with self-hosted runners. D) OIDC tokens are valid for 30 days. Answer: A Explanation: OIDC tokens are short-lived (≈1 hour) and can be exchanged for cloud provider credentials, reducing secret exposure. Question 36. How can you enforce that only actions from a specific organization can be used in a repository? A) Add the organization to allowed_actions in the repository’s CODEOWNERS. B) Configure allowed_actions in the repository’s security policy (.github/settings.yml). C) Set actions.trusted in the repository settings UI. D) Use a workflow-level if condition to block others. Answer: B Explanation: The allowed_actions policy in the repository or organization settings restricts which actions can be run. Question 37. Which artifact attestation format is recommended for supply-chain security? A) SPDX B) CycloneDX
C) SLSA provenance D) OpenSSF Scorecard Answer: C Explanation: SLSA (Supply-Chain Levels for Software Artifacts) provenance provides cryptographic attestations of build steps. Question 38. What does the concurrency keyword prevent in a workflow? A) Multiple jobs from running in parallel on the same runner. B) Duplicate workflow runs with the same concurrency group from executing simultaneously. C) The workflow from being triggered by pull requests. D) The use of self-hosted runners. Answer: B Explanation: concurrency groups runs; if a new run is queued with the same group, the previous one can be cancelled. Question 39. Which setting controls how long workflow run logs are retained at the organization level? A) log-retention-days in .github/workflows/*.yml B) Organization → Settings → Actions → Artifact and log retention C) retention-days under each job definition D) Environment variable LOG_RETENTION Answer: B Explanation: The organization settings page lets admins define default retention periods for logs and artifacts. Question 40. How can you limit a job to run only on a self-hosted runner group named linux-builders?
Question 43. Which of the following is not a valid way to reference a repository-level secret in a workflow? A) ${{ secrets.MY_SECRET }} B) ${{ env.MY_SECRET }} after exporting it C) secrets.MY_SECRET without the ${{ }} syntax D) Using the secret as an input to a reusable workflow via with: Answer: C Explanation: Secrets must be interpolated using ${{ }}; raw secrets.MY_SECRET is not parsed. Question 44. How can you make a workflow automatically delete its artifacts after 7 days? A) Set retention-days: 7 under the upload-artifact step. B) Add artifact-retention-days: 7 in the workflow file header. C) Include retention-days: 7 in the jobs..steps block. D) Use the repository’s default artifact retention setting. Answer: A Explanation: The actions/upload-artifact action accepts a retention-days input to control artifact lifespan. Question 45. Which statement about actions/cache is true? A) It automatically restores caches on every run regardless of the key. B) The cache is shared across all branches by default. C) Cache entries are immutable; a new key creates a new cache. D) Caches are stored indefinitely unless manually deleted. Answer: C
Explanation: Once a cache is created for a key, it cannot be overwritten; new keys generate new caches. Question 46. In a composite action, which file defines the sequence of steps? A) Dockerfile B) action.yml with a runs: using: composite block containing steps: C) main.js D) workflow.yml Answer: B Explanation: Composite actions list their steps directly in the action.yml under the runs block. Question 47. Which of the following is a correct way to reference a runner’s toolcache directory for Node.js? A) $RUNNER_TOOL_CACHE/node B) ${{ runner.tool_cache }}/node C) $RUNNER_TOOL_CACHE/node (environment variable) D) ${{ env.RUNNER_TOOL_CACHE }}/node Answer: C Explanation: RUNNER_TOOL_CACHE is an environment variable automatically set on the runner. Question 48. How does the needs keyword affect artifact sharing between jobs? A) It automatically copies all artifacts from the needed job. B) It allows the dependent job to download artifacts using actions/download- artifact with if: needs..outputs.artifact-id. C) It does not affect artifact sharing; artifacts must be explicitly uploaded/downloaded.
B) on: pull_request_target:\n branches: [ develop ] C) on: pull_request:\n types: [ opened, synchronize ]\n branches: [ develop ] D) on: pull_request:\n branches-ignore: [ main ] Answer: D Explanation: branches-ignore excludes branches but does not specifically target develop; it would still run on any other branch. Question 52. How can you make a step fail without stopping the entire job? A) continue-on-error: true on the step. B) if: failure() on the step. C) fail-fast: false on the job. D) ignore-errors: true on the step. Answer: A Explanation: continue-on-error allows the step to report failure but lets the job continue. Question 53. Which of the following is a correct way to pass a JSON string as an input to an action? A) with:\n config: '{"debug":true}' B) with:\n config: '{\"debug\":true}' C) with:\n config: ${{ toJSON({debug:true}) }} D) All of the above are valid. Answer: D Explanation: All three syntaxes correctly provide a JSON string; the third uses an expression to generate it. Question 54. What is the effect of setting permissions: contents: read at the top of a workflow file?
A) It grants the GITHUB_TOKEN read access to repository contents and removes other default permissions. B) It disables all permissions for the workflow. C) It only applies to actions marketplace publishing. D) It overrides repository-level permissions for all users. Answer: A Explanation: The permissions block customizes the token’s scopes; unspecified scopes default to none. Question 55. Which of the following best describes a “runner group” in GitHub Enterprise? A) A collection of Docker images used by actions. B) A logical set of self-hosted runners that can be assigned to repositories with specific access controls. C) A list of public runners provided by GitHub. D) A set of environment variables shared across jobs. Answer: B Explanation: Runner groups let administrators organize self-hosted runners and control which repositories may use them. Question 56. How can you ensure that a workflow does not run on forked repositories? A) Add if: github.repository == 'owner/repo' at the workflow level. B) Use permissions: none in the workflow. C) Set workflow_run trigger with types: [requested]. D) Define runs-on: self-hosted only. Answer: A Explanation: Comparing github.repository to the canonical repo name prevents execution on forks.