QCM Mock Exam
QCM Mock Exam
A/ on:
pull_request:
branches:
- main
B/ on:
pull_request:
types:
- main
C/ on: push
D/ on: fork
2/You have created a secret named api_key to use in a workflow that deploys a new
application. Which of the following is the correct syntax to reference the secret as
an environment variable?
A/ steps:
- shell: bash
env:
ENV_API_KEY: ${{ secrets.environment.api_key }}
run: |
./app_install.sh
B/ steps:
- shell: bash
with:
ENV_API_KEY = api_key
run: |
./app_install.sh
C/ steps:
- shell: bash
with:
ENV_API_KEY: ${{ api_key }}
run: |
./app_install.sh
D/ steps:
- shell: bash
env:
ENV_API_KEY: ${{ secrets.api_key }}
run: |
./app_install.sh
3/You have developed a new GitHub Action and want to share it with the greater
community. Where should you publish it?
A/a public repository
B/a private repository
C/GitHub Marketplace
D/personal blog or website
4/ What will the value of the NAME variable be when this workflow is triggered?
name: CI
env:
NAME: 'My Action'
on:
push:
branches: [ "main" ]
jobs:
build:
env:
NAME: 'My Action 2'
runs-on: ubuntu-latest
- name: Print name
run: echo "$NAME"
env:
NAME: 'My Action 3'
A/ My Action
B/ My Action 3
C/ this run will error because of incorrect syntax
D/ My Action 2
function getUserName(user) {
return user?.name || 'Guest';
}
test('returns the user name when user is provided', () => {
expect(getUserName({ name: 'Alice' })).toBe('Alice');
});
test('returns "Guest" when user is null', () => {
expect(getUserName(null)).toBe('Guest');
});
test('returns "Guest" when user object has no name property', () => {
expect(getUserName({})).toBe('Guest');
});
8/ What additional steps does GitHub add to each job in a workflow run?
A/ "Checkout" and "Post-job cleanup"
B/ “Set up job” and “Complete job”
C/ "Set up job" and "Tear down job"
D/ GitHub does not add any steps to a job. All steps must be configured in
the workflow file.
9/ You want to configure a GitHub Actions workflow to run only for specific activity
types triggered by a webhook event payload. Which keyword should you use in your
workflow configuration, and how can you restrict it to specific activity types?