Skip to content

Commit 6c3788c

Browse files
crichIDJasonEtco
andauthored
Add code block copy button to more actions guides code blocks (#16213)
* add copy to code blocks in about service containers * add copy to code blocks in java with ant guide * add copy to code blocks in actions guides * Update content/actions/guides/about-service-containers.md Co-authored-by: Jason Etcovitch <jasonetco@github.com> * {:code} should be {:copy} * add copy button in reusable Co-authored-by: Jason Etcovitch <jasonetco@github.com>
1 parent 4bb7dd8 commit 6c3788c

15 files changed

Lines changed: 72 additions & 72 deletions

content/actions/guides/about-service-containers.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ You can use the `services` keyword to create service containers that are part of
4747
This example creates a service called `redis` in a job called `container-job`. The Docker host in this example is the `node:10.18-jessie` container.
4848

4949
{% raw %}
50-
```yaml
50+
```yaml{:copy}
5151
name: Redis container example
5252
on: push
5353
@@ -89,7 +89,7 @@ When you specify the Docker host port but not the container port, the container
8989
This example maps the service container `redis` port 6379 to the Docker host port 6379.
9090

9191
{% raw %}
92-
```yaml
92+
```yaml{:copy}
9393
name: Redis Service Example
9494
on: push
9595

content/actions/guides/building-and-testing-java-with-ant.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Ant template when you c
3838
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
3939

4040
{% raw %}
41-
```yaml
41+
```yaml{:copy}
4242
name: Java CI
4343
4444
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the default target specified in your _build.xml_ f
7979
If you use different commands to build your project, or you want to run a different target, you can specify those. For example, you may want to run the `jar` target that's configured in your _build-ci.xml_ file.
8080

8181
{% raw %}
82-
```yaml
82+
```yaml{:copy}
8383
steps:
8484
- uses: actions/checkout@v2
8585
- uses: actions/setup-java@v1
@@ -97,7 +97,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
9797
Ant will usually create output files like JARs, EARs, or WARs in the `build/jar` directory. You can upload the contents of that directory using the `upload-artifact` action.
9898

9999
{% raw %}
100-
```yaml
100+
```yaml{:copy}
101101
steps:
102102
- uses: actions/checkout@v2
103103
- uses: actions/setup-java@v1

content/actions/guides/building-and-testing-java-with-gradle.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Gradle template when yo
3838
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
3939

4040
{% raw %}
41-
```yaml
41+
```yaml{:copy}
4242
name: Java CI
4343
4444
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the `build` task by default. In the default Gradle
7979
If you use different commands to build your project, or you want to use a different task, you can specify those. For example, you may want to run the `package` task that's configured in your _ci.gradle_ file.
8080

8181
{% raw %}
82-
```yaml
82+
```yaml{:copy}
8383
steps:
8484
- uses: actions/checkout@v2
8585
- uses: actions/setup-java@v1
@@ -95,7 +95,7 @@ steps:
9595
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Gradle package cache will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote package repositories. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
9696

9797
{% raw %}
98-
```yaml
98+
```yaml{:copy}
9999
steps:
100100
- uses: actions/checkout@v2
101101
- name: Set up JDK 1.8
@@ -122,7 +122,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
122122
Gradle will usually create output files like JARs, EARs, or WARs in the `build/libs` directory. You can upload the contents of that directory using the `upload-artifact` action.
123123

124124
{% raw %}
125-
```yaml
125+
```yaml{:copy}
126126
steps:
127127
- uses: actions/checkout@v2
128128
- uses: actions/setup-java@v1

content/actions/guides/building-and-testing-java-with-maven.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ To get started quickly, you can choose the preconfigured Maven template when you
3838
You can also add this workflow manually by creating a new file in the `.github/workflows` directory of your repository.
3939

4040
{% raw %}
41-
```yaml
41+
```yaml{:copy}
4242
name: Java CI
4343
4444
on: [push]
@@ -79,7 +79,7 @@ The starter workflow will run the `package` target by default. In the default Ma
7979
If you use different commands to build your project, or you want to use a different target, you can specify those. For example, you may want to run the `verify` target that's configured in a _pom-ci.xml_ file.
8080

8181
{% raw %}
82-
```yaml
82+
```yaml{:copy}
8383
steps:
8484
- uses: actions/checkout@v2
8585
- uses: actions/setup-java@v1
@@ -95,7 +95,7 @@ steps:
9595
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache your dependencies to speed up your workflow runs. After a successful run, your local Maven repository will be stored on GitHub Actions infrastructure. In future workflow runs, the cache will be restored so that dependencies don't need to be downloaded from remote Maven repositories. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
9696

9797
{% raw %}
98-
```yaml
98+
```yaml{:copy}
9999
steps:
100100
- uses: actions/checkout@v2
101101
- name: Set up JDK 1.8
@@ -122,7 +122,7 @@ After your build has succeeded and your tests have passed, you may want to uploa
122122
Maven will usually create output files like JARs, EARs, or WARs in the `target` directory. To upload those as artifacts, you can copy them into a new directory that contains artifacts to upload. For example, you can create a directory called `staging`. Then you can upload the contents of that directory using the `upload-artifact` action.
123123

124124
{% raw %}
125-
```yaml
125+
```yaml{:copy}
126126
steps:
127127
- uses: actions/checkout@v2
128128
- uses: actions/setup-java@v1

content/actions/guides/building-and-testing-nodejs.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ The template includes a matrix strategy that builds and tests your code with fou
7777
Each job can access the value defined in the matrix `node-version` array using the `matrix` context. The `setup-node` action uses the context as the `node-version` input. The `setup-node` action configures each job with a different Node.js version before building and testing code. For more information about matrix strategies and contexts, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategymatrix)" and "[Context and expression syntax for {% data variables.product.prodname_actions %}](/actions/reference/context-and-expression-syntax-for-github-actions)."
7878

7979
{% raw %}
80-
```yaml
80+
```yaml{:copy}
8181
strategy:
8282
matrix:
8383
node-version: [10.x, 12.x, 14.x, 15.x]
@@ -93,7 +93,7 @@ steps:
9393

9494
Alternatively, you can build and test with exact Node.js versions.
9595

96-
```yaml
96+
```yaml{:copy}
9797
strategy:
9898
matrix:
9999
node-version: [8.16.2, 10.17.0]
@@ -102,7 +102,7 @@ strategy:
102102
Or, you can build and test using a single version of Node.js too.
103103

104104
{% raw %}
105-
```yaml
105+
```yaml{:copy}
106106
name: Node.js CI
107107
108108
on: [push]
@@ -136,7 +136,7 @@ When using {% data variables.product.prodname_dotcom %}-hosted runners, you can
136136

137137
This example installs the dependencies defined in the *package.json* file. For more information, see [`npm install`](https://docs.npmjs.com/cli/install).
138138

139-
```yaml
139+
```yaml{:copy}
140140
steps:
141141
- uses: actions/checkout@v2
142142
- name: Use Node.js
@@ -150,7 +150,7 @@ steps:
150150
Using `npm ci` installs the versions in the *package-lock.json* or *npm-shrinkwrap.json* file and prevents updates to the lock file. Using `npm ci` is generally faster than running `npm install`. For more information, see [`npm ci`](https://docs.npmjs.com/cli/ci.html) and "[Introducing `npm ci` for faster, more reliable builds](https://blog.npmjs.org/post/171556855892/introducing-npm-ci-for-faster-more-reliable)."
151151

152152
{% raw %}
153-
```yaml
153+
```yaml{:copy}
154154
steps:
155155
- uses: actions/checkout@v2
156156
- name: Use Node.js
@@ -166,7 +166,7 @@ steps:
166166

167167
This example installs the dependencies defined in the *package.json* file. For more information, see [`yarn install`](https://yarnpkg.com/en/docs/cli/install).
168168

169-
```yaml
169+
```yaml{:copy}
170170
steps:
171171
- uses: actions/checkout@v2
172172
- name: Use Node.js
@@ -179,7 +179,7 @@ steps:
179179

180180
Alternatively, you can pass `--frozen-lockfile` to install the versions in the *yarn.lock* file and prevent updates to the *yarn.lock* file.
181181

182-
```yaml
182+
```yaml{:copy}
183183
steps:
184184
- uses: actions/checkout@v2
185185
- name: Use Node.js
@@ -201,7 +201,7 @@ In the example below, the secret `NPM_TOKEN` stores the npm authentication token
201201
Before installing dependencies, use the `setup-node` action to create the *.npmrc* file. The action has two input parameters. The `node-version` parameter sets the Node.js version, and the `registry-url` parameter sets the default registry. If your package registry uses scopes, you must use the `scope` parameter. For more information, see [`npm-scope`](https://docs.npmjs.com/misc/scope).
202202

203203
{% raw %}
204-
```yaml
204+
```yaml{:copy}
205205
steps:
206206
- uses: actions/checkout@v2
207207
- name: Use Node.js
@@ -231,7 +231,7 @@ always-auth=true
231231
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can cache dependencies using a unique key, and restore the dependencies when you run future workflows using the `cache` action. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>" and the [`cache` action](https://github.com/marketplace/actions/cache).
232232

233233
{% raw %}
234-
```yaml
234+
```yaml{:copy}
235235
steps:
236236
- uses: actions/checkout@v2
237237
- name: Use Node.js
@@ -256,7 +256,7 @@ steps:
256256

257257
You can use the same commands that you use locally to build and test your code. For example, if you run `npm run build` to run build steps defined in your *package.json* file and `npm test` to run your test suite, you would add those commands in your workflow file.
258258

259-
```yaml
259+
```yaml{:copy}
260260
steps:
261261
- uses: actions/checkout@v2
262262
- name: Use Node.js

content/actions/guides/building-and-testing-python.md

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ We recommend that you have a basic understanding of Python, PyPy, and pip. For m
3737
To get started quickly, add the template to the `.github/workflows` directory of your repository.
3838

3939
{% raw %}
40-
```yaml
40+
```yaml{:copy}
4141
name: Python package
4242
4343
on: [push]
@@ -94,7 +94,7 @@ If you are using a self-hosted runner, you can configure the runner to use the `
9494
#### Using multiple Python versions
9595

9696
{% raw %}
97-
```yaml
97+
```yaml{:copy}
9898
name: Python package
9999
100100
on: [push]
@@ -126,7 +126,7 @@ jobs:
126126
You can configure a specific version of python. For example, 3.8. Alternatively, you can use semantic version syntax to get the latest minor release. This example uses the latest minor release of Python 3.
127127

128128
{% raw %}
129-
```yaml
129+
```yaml{:copy}
130130
name: Python package
131131
132132
on: [push]
@@ -158,7 +158,7 @@ If you specify a version of Python that is not available, `setup-python` fails w
158158
You can also use the `exclude` keyword in your workflow if there is a configuration of Python that you do not wish to run. For more information, see "[Workflow syntax for {% data variables.product.prodname_actions %}](/actions/automating-your-workflow-with-github-actions/workflow-syntax-for-github-actions#jobsjob_idstrategy)."
159159

160160
{% raw %}
161-
```yaml
161+
```yaml{:copy}
162162
name: Python package
163163
164164
on: [push]
@@ -196,7 +196,7 @@ We recommend using `setup-python` to configure the version of Python used in you
196196
When using {% data variables.product.prodname_dotcom %}-hosted runners, you can also cache dependencies to speed up your workflow. For more information, see "<a href="/actions/guides/caching-dependencies-to-speed-up-workflows" class="dotcom-only">Caching dependencies to speed up workflows</a>."
197197

198198
{% raw %}
199-
```yaml
199+
```yaml{:copy}
200200
steps:
201201
- uses: actions/checkout@v2
202202
- name: Set up Python
@@ -213,7 +213,7 @@ steps:
213213
After you update `pip`, a typical next step is to install dependencies from *requirements.txt*.
214214

215215
{% raw %}
216-
```yaml
216+
```yaml{:copy}
217217
steps:
218218
- uses: actions/checkout@v2
219219
- name: Set up Python
@@ -234,7 +234,7 @@ When using {% data variables.product.prodname_dotcom %}-hosted runners, you can
234234
Pip caches dependencies in different locations, depending on the operating system of the runner. The path you'll need to cache may differ from the Ubuntu example below depending on the operating system you use. For more information, see [Python caching examples](https://github.com/actions/cache/blob/main/examples.md#python---pip).
235235

236236
{% raw %}
237-
```yaml
237+
```yaml{:copy}
238238
steps:
239239
- uses: actions/checkout@v2
240240
- name: Setup Python
@@ -271,7 +271,7 @@ You can use the same commands that you use locally to build and test your code.
271271
This example installs or upgrades `pytest` and `pytest-cov`. Tests are then run and output in JUnit format while code coverage results are output in Cobertura. For more information, see [JUnit](https://junit.org/junit5/) and [Cobertura](https://cobertura.github.io/cobertura/).
272272

273273
{% raw %}
274-
```yaml
274+
```yaml{:copy}
275275
steps:
276276
- uses: actions/checkout@v2
277277
- name: Set up Python
@@ -295,7 +295,7 @@ steps:
295295
The following example installs or upgrades `flake8` and uses it to lint all files. For more information, see [Flake8](http://flake8.pycqa.org/en/latest/).
296296

297297
{% raw %}
298-
```yaml
298+
```yaml{:copy}
299299
steps:
300300
- uses: actions/checkout@v2
301301
- name: Set up Python
@@ -318,7 +318,7 @@ steps:
318318
With {% data variables.product.prodname_actions %}, you can run tests with tox and spread the work across multiple jobs. You'll need to invoke tox using the `-e py` option to choose the version of Python in your `PATH`, rather than specifying a specific version. For more information, see [tox](https://tox.readthedocs.io/en/latest/).
319319

320320
{% raw %}
321-
```yaml
321+
```yaml{:copy}
322322
name: Python package
323323
324324
on: [push]
@@ -352,7 +352,7 @@ You can upload artifacts to view after a workflow completes. For example, you ma
352352
The following example demonstrates how you can use the `upload-artifact` action to archive test results from running `pytest`. For more information, see the [`upload-artifact` action](https://github.com/actions/upload-artifact).
353353

354354
{% raw %}
355-
```yaml
355+
```yaml{:copy}
356356
name: Python package
357357
358358
on: [push]
@@ -395,7 +395,7 @@ You can configure your workflow to publish your Python package to any package re
395395
You can store any access tokens or credentials needed to publish your package using secrets. The following example creates and publishes a package to PyPI using `twine` and `dist`. For more information, see "[Creating and using encrypted secrets](/github/automating-your-workflow-with-github-actions/creating-and-using-encrypted-secrets)."
396396

397397
{% raw %}
398-
```yaml
398+
```yaml{:copy}
399399
name: Upload Python Package
400400
401401
on:

content/actions/guides/caching-dependencies-to-speed-up-workflows.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,7 @@ For more information, see [`actions/cache`](https://github.com/actions/cache).
6868
This example creates a new cache when the packages in `package-lock.json` file change, or when the runner's operating system changes. The cache key uses contexts and expressions to generate a key that includes the runner's operating system and a SHA-256 hash of the `package-lock.json` file.
6969

7070
{% raw %}
71-
```yaml
71+
```yaml{:copy}
7272
name: Caching with npm
7373
7474
on: push

content/actions/guides/creating-postgresql-service-containers.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ You may also find it helpful to have a basic understanding of YAML, the syntax f
3737
{% data reusables.github-actions.copy-workflow-file %}
3838

3939
{% raw %}
40-
```yaml
40+
```yaml{:copy}
4141
name: PostgreSQL service example
4242
on: push
4343
@@ -94,7 +94,7 @@ jobs:
9494

9595
{% data reusables.github-actions.postgres-label-description %}
9696

97-
```yaml
97+
```yaml{:copy}
9898
jobs:
9999
# Label of the container job
100100
container-job:
@@ -124,7 +124,7 @@ jobs:
124124

125125
{% data reusables.github-actions.service-template-steps %}
126126

127-
```yaml
127+
```yaml{:copy}
128128
steps:
129129
# Downloads a copy of the code in your repository before running CI tests
130130
- name: Check out repository code
@@ -159,7 +159,7 @@ When you run a job directly on the runner machine, you'll need to map the ports
159159
{% data reusables.github-actions.copy-workflow-file %}
160160

161161
{% raw %}
162-
```yaml
162+
```yaml{:copy}
163163
name: PostgreSQL Service Example
164164
on: push
165165
@@ -220,7 +220,7 @@ jobs:
220220

221221
The workflow maps port 5432 on the PostgreSQL service container to the Docker host. For more information about the `ports` keyword, see "[About service containers](/actions/automating-your-workflow-with-github-actions/about-service-containers#mapping-docker-host-and-service-container-ports)."
222222

223-
```yaml
223+
```yaml{:copy}
224224
jobs:
225225
# Label of the runner job
226226
runner-job:
@@ -251,7 +251,7 @@ jobs:
251251

252252
{% data reusables.github-actions.service-template-steps %}
253253

254-
```yaml
254+
```yaml{:copy}
255255
steps:
256256
# Downloads a copy of the code in your repository before running CI tests
257257
- name: Check out repository code
@@ -287,7 +287,7 @@ You can modify *client.js* to include any PostgreSQL operations needed by your w
287287

288288
{% data reusables.github-actions.service-container-add-script %}
289289

290-
```javascript
290+
```javascript{:copy}
291291
const { Client } = require('pg');
292292
293293
const pgclient = new Client({

0 commit comments

Comments
 (0)