Skip to content

Commit 2758eba

Browse files
authored
Merge pull request #39315 from github/repo-sync
Repo sync
2 parents 32a9f89 + 25cb69c commit 2758eba

File tree

49 files changed

+3138
-822
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

49 files changed

+3138
-822
lines changed
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
---
22
title: Using conditions to control job execution
3-
shortTitle: Use conditions to control job execution
3+
shortTitle: Control jobs with conditions
44
intro: Prevent a job from running unless your conditions are met.
55
versions:
66
fpt: '*'
@@ -11,15 +11,28 @@ redirect_from:
1111
- /actions/writing-workflows/choosing-when-your-workflow-runs/using-conditions-to-control-job-execution
1212
---
1313

14-
{% data reusables.actions.enterprise-github-hosted-runners %}
14+
You can use the `jobs.<job_id>.if` conditional to prevent a job from running unless a condition is met. {% data reusables.actions.if-supported-contexts %}
1515

16-
## Overview
16+
### Example: Only run job for a specific repository
1717

18-
{% data reusables.actions.workflows.skipped-job-status-checks-passing %}
18+
This example uses `if` to control when the `production-deploy` job can run. It will only run if the repository is named `octo-repo-prod` and is within the `octo-org` organization. Otherwise, the job will be marked as _skipped_.
1919

20-
{% data reusables.actions.jobs.section-using-conditions-to-control-job-execution %}
20+
```yaml copy
21+
name: example-workflow
22+
on: [push]
23+
jobs:
24+
production-deploy:
25+
if: github.repository == 'octo-org/octo-repo-prod'
26+
runs-on: ubuntu-latest
27+
steps:
28+
- uses: {% data reusables.actions.action-checkout %}
29+
- uses: {% data reusables.actions.action-setup-node %}
30+
with:
31+
node-version: '14'
32+
- run: npm install -g bats
33+
```
2134
22-
On a skipped job, you should see "This check was skipped."
35+
Skipped jobs display the message "This check was skipped."
2336
2437
> [!NOTE]
25-
> In some parts of the workflow you cannot use environment variables. Instead you can use contexts to access the value of an environment variable. For more information, see [AUTOTITLE](/actions/learn-github-actions/variables#using-the-env-context-to-access-environment-variable-values).
38+
> A job that is skipped will report its status as "Success". It will not prevent a pull request from merging, even if it is a required check.

data/reusables/actions/about-deployment-with-github-actions.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

data/reusables/actions/environment-example.md

Lines changed: 0 additions & 43 deletions
This file was deleted.

data/reusables/actions/reusable-workflow-artifacts.md

Lines changed: 0 additions & 1 deletion
This file was deleted.

src/events/components/experiments/experiments.ts

Lines changed: 11 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,20 +15,19 @@ type Experiment = {
1515
}
1616

1717
// Update this with the name of the experiment, e.g. | 'example_experiment'
18-
export type ExperimentNames = 'ai_search_experiment'
18+
export type ExperimentNames = 'placeholder_experiment'
1919

2020
export const EXPERIMENTS = {
21-
ai_search_experiment: {
22-
key: 'ai_search_experiment',
23-
isActive: true, // Set to false when the experiment is over
24-
// We still use an experiment for the AI Search until we:
25-
// 1. Move analytics over the main dashboard
26-
// 2. Don't require an emergency rollback, which experiments provides us
27-
percentOfUsersToGetExperiment: 100, // 100% of users will get the experiment
28-
includeVariationInContext: true, // All events will include the `experiment_variation` of the `ai_search_experiment`
29-
limitToLanguages: ['en'], // Only users with the `en` language will be included in the experiment
30-
alwaysShowForStaff: true, // When set to true, staff will always see the experiment (determined by the `staffonly` cookie)
31-
turnOnWithURLParam: 'ai_search', /// When the query param `?feature=ai_search` is set, the experiment will be enabled
21+
// Placeholder experiment to maintain type compatibility
22+
placeholder_experiment: {
23+
key: 'placeholder_experiment',
24+
isActive: false, // Inactive placeholder
25+
percentOfUsersToGetExperiment: 0,
26+
includeVariationInContext: false,
27+
limitToLanguages: [],
28+
limitToVersions: [],
29+
alwaysShowForStaff: false,
30+
turnOnWithURLParam: 'placeholder', // Placeholder URL param
3231
},
3332
/* Add new experiments here, example:
3433
'example_experiment': {

src/fixtures/helpers/turn-off-experiments.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,3 +44,18 @@ export function turnOffExperimentsBeforeEach(test: typeof Test) {
4444
await turnOffExperimentsInPage(page)
4545
})
4646
}
47+
48+
export async function dismissCTAPopover(page: Page) {
49+
// Set the CTA popover to permanently dismissed in localStorage
50+
await page.evaluate(() => {
51+
localStorage.setItem(
52+
'ctaPopoverState',
53+
JSON.stringify({
54+
dismissedCount: 0,
55+
lastDismissedAt: null,
56+
permanentlyDismissed: true,
57+
}),
58+
)
59+
})
60+
await page.reload()
61+
}

src/fixtures/tests/playwright-local-dev.spec.ts

Lines changed: 17 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -12,38 +12,49 @@
1212
*/
1313

1414
import { test, expect } from '@playwright/test'
15-
import { turnOffExperimentsInPage } from '../helpers/turn-off-experiments'
15+
import { dismissCTAPopover, turnOffExperimentsInPage } from '../helpers/turn-off-experiments'
1616

1717
const TEST_EARLY_ACCESS = Boolean(JSON.parse(process.env.TEST_EARLY_ACCESS || 'false'))
1818

1919
test('view home page', async ({ page }) => {
2020
await page.goto('/')
2121
await turnOffExperimentsInPage(page)
22+
await dismissCTAPopover(page)
23+
2224
await expect(page).toHaveTitle(/GitHub Docs/)
2325
})
2426

2527
test('click "Get started" from home page', async ({ page }) => {
2628
await page.goto('/')
2729
await turnOffExperimentsInPage(page)
30+
await dismissCTAPopover(page)
31+
2832
await page.getByRole('link', { name: 'Get started' }).click()
2933
await expect(page).toHaveTitle(/Get started with GitHub/)
3034
await expect(page).toHaveURL(/\/en\/get-started/)
3135
})
3236

33-
test('search "git" and get results', async ({ page }) => {
37+
test('search "foo" and get results', async ({ page }) => {
3438
await page.goto('/')
3539
await turnOffExperimentsInPage(page)
36-
await page.getByTestId('site-search-input').click()
37-
await page.getByTestId('site-search-input').fill('git')
38-
await page.getByTestId('site-search-input').press('Enter')
39-
await expect(page.getByRole('heading', { name: /\d+ Search results for "git"/ })).toBeVisible()
40+
await dismissCTAPopover(page)
41+
42+
await page.locator('[data-testid="search"]:visible').click()
43+
await page.getByTestId('overlay-search-input').fill('foo')
44+
// Wait for search results to load
45+
await page.waitForTimeout(1000)
46+
// Click "View more results" to get to the search page
47+
await page.getByText('View more results').click()
48+
await expect(page.getByRole('heading', { name: /\d+ Search results for "foo"/ })).toBeVisible()
4049
})
4150

4251
test('view the early-access links page', async ({ page }) => {
4352
if (!TEST_EARLY_ACCESS) return
4453

4554
await page.goto('/early-access')
4655
await turnOffExperimentsInPage(page)
56+
await dismissCTAPopover(page)
57+
4758
await expect(page).toHaveURL(/\/en\/early-access/)
4859
await page.getByRole('heading', { name: 'Early Access documentation', level: 1 }).click()
4960
const links = await page.$$eval(

0 commit comments

Comments
 (0)