Skip to content

Commit

Permalink
Merge branch 'main' into all-contributors/add-jeffmcaffer
Browse files Browse the repository at this point in the history
  • Loading branch information
janiceilene authored Oct 9, 2020
2 parents dff608c + 83f2e38 commit 2294987
Show file tree
Hide file tree
Showing 17 changed files with 210 additions and 116 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,10 @@ As you're using the GitHub Docs, you may find something in an article that you'd

If you've found a problem, you can open an issue using a [template](https://github.com/github/docs/issues/new/choose).

#### Solve an issue

If you have a solution to one of the open issues, you will need to fork the repository and submit a PR using the [template](https://github.com/github/docs/blob/main/CONTRIBUTING.md#pull-request-template) that is visible automatically in the pull request body. For more details about this process, please check out [Getting Started with Contributing](/CONTRIBUTING.md).

#### Join us in discussions

We use GitHub Discussions to talk about all sorts of topics related to documentation and this site. For example: if you'd like help troubleshooting a PR, have a great new idea, or want to share something amazing you've learned in our docs, join us in [discussions](https://github.com/github/docs/discussions).
Expand Down
194 changes: 95 additions & 99 deletions content/actions/guides/storing-workflow-data-as-artifacts.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,9 @@ versions:

### About workflow artifacts

Artifacts allow you to persist data after a job has completed, and share that data with another job in the same workflow. An artifact is a file or collection of files produced during a workflow run. For example, you can use artifacts to save your build and test output after a workflow run has ended. For pushes and pull requests, {% data variables.product.product_name %} stores artifacts for 90 days. The retention period for a pull request restarts each time someone pushes a new commit to the pull request.
Artifacts allow you to persist data after a job has completed, and share that data with another job in the same workflow. An artifact is a file or collection of files produced during a workflow run. For example, you can use artifacts to save your build and test output after a workflow run has ended.

{% data reusables.github-actions.artifact-log-retention-statement %} The retention period for a pull request restarts each time someone pushes a new commit to the pull request.

These are some of the common artifacts that you can upload:

Expand Down Expand Up @@ -48,89 +50,6 @@ To share data between jobs:

The steps of a job share the same environment on the runner machine, but run in their own individual processes. To pass data between steps in a job, you can use inputs and outputs. For more information about inputs and outputs, see "[Metadata syntax for {% data variables.product.prodname_actions %}](/articles/metadata-syntax-for-github-actions)."

### Passing data between jobs in a workflow

You can use the `upload-artifact` and `download-artifact` actions to share data between jobs in a workflow. This example workflow illustrates how to pass data between jobs in the same workflow. For more information, see the {% if currentVersion == "free-pro-team@latest" %}[actions/upload-artifact](https://github.com/actions/upload-artifact) and [download-artifact](https://github.com/actions/download-artifact) actions{% else %} `actions/upload-artifact` and `download-artifact` actions on {% data variables.product.product_location %}{% endif %}.

Jobs that are dependent on a previous job's artifacts must wait for the dependent job to complete successfully. This workflow uses the `needs` keyword to ensure that `job_1`, `job_2`, and `job_3` run sequentially. For example, `job_2` requires `job_1` using the `needs: job_1` syntax.

Job 1 performs these steps:
- Performs a math calculation and saves the result to a text file called `math-homework.txt`.
- Uses the `upload-artifact` action to upload the `math-homework.txt` file with the name `homework`. The action places the file in a directory named `homework`.

Job 2 uses the result in the previous job:
- Downloads the `homework` artifact uploaded in the previous job. By default, the `download-artifact` action downloads artifacts to the workspace directory that the step is executing in. You can use the `path` input parameter to specify a different download directory.
- Reads the value in the `homework/math-homework.txt` file, performs a math calculation, and saves the result to `math-homework.txt`.
- Uploads the `math-homework.txt` file. This upload overwrites the previous upload because both of the uploads share the same name.

Job 3 displays the result uploaded in the previous job:
- Downloads the `homework` artifact.
- Prints the result of the math equation to the log.

The full math operation performed in this workflow example is `(3 + 7) x 9 = 90`.

```yaml
name: Share data between jobs

on: [push]

jobs:
job_1:
name: Add 3 and 7
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
expr 3 + 7 > math-homework.txt
- name: Upload math result for job 1
uses: actions/upload-artifact@v2
with:
name: homework
path: math-homework.txt

job_2:
name: Multiply by 9
needs: job_1
runs-on: windows-latest
steps:
- name: Download math result for job 1
uses: actions/download-artifact@v2
with:
name: homework
- shell: bash
run: |
value=`cat math-homework.txt`
expr $value \* 9 > math-homework.txt
- name: Upload math result for job 2
uses: actions/upload-artifact@v2
with:
name: homework
path: math-homework.txt

job_3:
name: Display results
needs: job_2
runs-on: macOS-latest
steps:
- name: Download math result for job 2
uses: actions/download-artifact@v2
with:
name: homework
- name: Print the final result
shell: bash
run: |
value=`cat math-homework.txt`
echo The result is $value
```
![Workflow that passes data between jobs to perform math](/assets/images/help/repository/passing-data-between-jobs-in-a-workflow.png)
### Sharing data between workflow runs
After a workflow ends, you can download a compressed file of the uploaded artifacts on {% data variables.product.product_name %} by finding the workflow run in the **Actions** tab. You can also use the {% data variables.product.prodname_dotcom %} REST API to download artifacts. For more information, see "[Artifacts](/v3/actions/artifacts/)."
If you need to access artifacts from a previous workflow run, you can use the {% data variables.product.product_name %} REST API to retrieve artifacts. For more information, see "[Get an artifact](/rest/reference/actions#artifacts)."
### Uploading build and test artifacts

You can create a continuous integration (CI) workflow to build and test your code. For more information about using {% data variables.product.prodname_actions %} to perform CI, see "[About continuous integration](/articles/about-continuous-integration)."
Expand Down Expand Up @@ -191,13 +110,32 @@ jobs:
![Image of workflow upload artifact workflow run](/assets/images/help/repository/upload-build-test-artifact.png)
{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "[email protected]" %}
### Configuring a custom artifact retention period
You can define a custom retention period for individual artifacts created by a workflow. When using a workflow to create a new artifact, you can use `retention-days` with the `upload-artifact` action. This example demonstrates how to set a custom retention period of 5 days for the artifact named `my-artifact`:

```
- name: 'Upload Artifact'
uses: actions/upload-artifact@v2
with:
name: my-artifact
path: my_file.txt
retention-days: 5
```
The `retention-days` value cannot exceed the retention limit set by the repository, organization, or enterprise.
{% endif %}
### Downloading or deleting artifacts
During a workflow run, you can download artifacts that were previously uploaded in the same workflow run. After a workflow run has been completed, you can download or delete artifacts on GitHub using the workflow run history.
During a workflow run, you can use the [`download-artifact`](https://github.com/actions/download-artifact)action to download artifacts that were previously uploaded in the same workflow run.
After a workflow run has been completed, you can download or delete artifacts on {% data variables.product.prodname_dotcom %} or using the REST API. For more information, see "[Downloading workflow artifacts](/actions/managing-workflow-runs/downloading-workflow-artifacts)," "[Removing workflow artifacts](/actions/managing-workflow-runs/removing-workflow-artifacts)," and the "[Artifacts REST API](/v3/actions/artifacts/)."
#### Downloading artifacts during a workflow run
The [actions/download-artifact](https://github.com/actions/download-artifact) action can be used to download previously uploaded artifacts during a workflow run.
The [`actions/download-artifact`](https://github.com/actions/download-artifact) action can be used to download previously uploaded artifacts during a workflow run.
{% note %}
Expand Down Expand Up @@ -225,24 +163,82 @@ If you download all a workflow run's artifacts, a directory for each artifact is
For more information on syntax, see the {% if currentVersion == "free-pro-team@latest" %}[actions/download-artifact](https://github.com/actions/download-artifact) action{% else %} `actions/download-artifact` action on {% data variables.product.product_location %}{% endif %}.

#### Downloading and deleting artifacts after a workflow run is complete
### Passing data between jobs in a workflow

You can use the `upload-artifact` and `download-artifact` actions to share data between jobs in a workflow. This example workflow illustrates how to pass data between jobs in the same workflow. For more information, see the {% if currentVersion == "free-pro-team@latest" %}[actions/upload-artifact](https://github.com/actions/upload-artifact) and [download-artifact](https://github.com/actions/download-artifact) actions{% else %} `actions/upload-artifact` and `download-artifact` actions on {% data variables.product.product_location %}{% endif %}.

Jobs that are dependent on a previous job's artifacts must wait for the dependent job to complete successfully. This workflow uses the `needs` keyword to ensure that `job_1`, `job_2`, and `job_3` run sequentially. For example, `job_2` requires `job_1` using the `needs: job_1` syntax.

Job 1 performs these steps:
- Performs a math calculation and saves the result to a text file called `math-homework.txt`.
- Uses the `upload-artifact` action to upload the `math-homework.txt` file with the name `homework`. The action places the file in a directory named `homework`.

Job 2 uses the result in the previous job:
- Downloads the `homework` artifact uploaded in the previous job. By default, the `download-artifact` action downloads artifacts to the workspace directory that the step is executing in. You can use the `path` input parameter to specify a different download directory.
- Reads the value in the `homework/math-homework.txt` file, performs a math calculation, and saves the result to `math-homework.txt`.
- Uploads the `math-homework.txt` file. This upload overwrites the previous upload because both of the uploads share the same name.

Job 3 displays the result uploaded in the previous job:
- Downloads the `homework` artifact.
- Prints the result of the math equation to the log.

The full math operation performed in this workflow example is `(3 + 7) x 9 = 90`.

```yaml
name: Share data between jobs
Artifacts automatically expire after 90 days, but you can always reclaim used {% data variables.product.prodname_actions %} storage by deleting artifacts before they expire on {% data variables.product.product_name %}.
on: [push]
{% warning %}
jobs:
job_1:
name: Add 3 and 7
runs-on: ubuntu-latest
steps:
- shell: bash
run: |
expr 3 + 7 > math-homework.txt
- name: Upload math result for job 1
uses: actions/upload-artifact@v2
with:
name: homework
path: math-homework.txt
**Warning:** Once you delete an artifact, it can not be restored.
job_2:
name: Multiply by 9
needs: job_1
runs-on: windows-latest
steps:
- name: Download math result for job 1
uses: actions/download-artifact@v2
with:
name: homework
- shell: bash
run: |
value=`cat math-homework.txt`
expr $value \* 9 > math-homework.txt
- name: Upload math result for job 2
uses: actions/upload-artifact@v2
with:
name: homework
path: math-homework.txt

{% endwarning %}
job_3:
name: Display results
needs: job_2
runs-on: macOS-latest
steps:
- name: Download math result for job 2
uses: actions/download-artifact@v2
with:
name: homework
- name: Print the final result
shell: bash
run: |
value=`cat math-homework.txt`
echo The result is $value
```
{% data reusables.repositories.navigate-to-repo %}
{% data reusables.repositories.actions-tab %}
{% data reusables.repositories.navigate-to-workflow %}
{% data reusables.repositories.view-run %}
1. To download artifacts, use the **Artifacts** drop-down menu, and select the artifact you want to download.
![Download artifact drop-down menu](/assets/images/help/repository/artifact-drop-down.png)
1. To delete artifacts, use the **Artifacts** drop-down menu, and click {% octicon "trashcan" aria-label="The trashcan icon" %}.
![Delete artifact drop-down menu](/assets/images/help/repository/actions-delete-artifact.png)
![Workflow that passes data between jobs to perform math](/assets/images/help/repository/passing-data-between-jobs-in-a-workflow.png)
{% if currentVersion == "free-pro-team@latest" %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Downloading workflow artifacts
intro: You can download artifacts that were archived during a workflow run. Artifacts automatically expire after 90 days.
intro: You can download archived artifacts before they automatically expire.
product: '{% data reusables.gated-features.actions %}'
versions:
free-pro-team: '*'
Expand All @@ -10,6 +10,9 @@ versions:
{% data reusables.actions.enterprise-beta %}
{% data reusables.actions.enterprise-github-hosted-runners %}

{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "[email protected]" %} By default, {% data variables.product.product_name %} stores build logs and artifacts for 90 days, and you can customize this retention period, depending on the type of repository. For more information, see "[Configuring the retention period for GitHub Actions artifacts and logs in your repository](/github/administering-a-repository/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-repository)."{% endif %}
{% if currentVersion == "[email protected]" %} {% data variables.product.product_name %} stores full build logs and artifacts for 90 days.{% endif %}

{% data reusables.repositories.permissions-statement-read %}

{% data reusables.repositories.navigate-to-repo %}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Removing workflow artifacts
intro: 'Artifacts automatically expire after 90 days, but you can always reclaim used {% data variables.product.prodname_actions %} storage by deleting artifacts before they expire on {% data variables.product.product_name %}.'
intro: 'You can reclaim used {% data variables.product.prodname_actions %} storage by deleting artifacts before they expire on {% data variables.product.product_name %}.'
product: '{% data reusables.gated-features.actions %}'
versions:
free-pro-team: '*'
Expand All @@ -10,6 +10,8 @@ versions:
{% data reusables.actions.enterprise-beta %}
{% data reusables.actions.enterprise-github-hosted-runners %}

### Deleting an artifact

{% warning %}

**Warning:** Once you delete an artifact, it can not be restored.
Expand All @@ -18,9 +20,23 @@ versions:

{% data reusables.repositories.permissions-statement-write %}

{% data reusables.github-actions.artifact-log-retention-statement %}

{% data reusables.repositories.navigate-to-repo %}
{% data reusables.repositories.actions-tab %}
{% data reusables.repositories.navigate-to-workflow %}
{% data reusables.repositories.view-run %}
1. Under **Artifacts**, click {% octicon "trashcan" aria-label="The trashcan icon" %} next to the artifact you want to remove.
![Delete artifact drop-down menu](/assets/images/help/repository/actions-delete-artifact.png)

{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "[email protected]" %}
### Setting the retention period for an artifact

Retention periods for artifacts and logs can be configured at the repository, organization, and enterprise level. For more information, see "[Usage limits, billing, and administration](/actions/reference/usage-limits-billing-and-administration#artifact-and-log-retention-policy)."

You can also define a custom retention period for individual artifacts using the `actions/upload-artifact` action in a workflow. For more information, see "[Storing workflow data as artifacts](/actions/guides/storing-workflow-data-as-artifacts#configuring-a-custom-artifact-retention-period)."

### Finding the expiration date of an artifact

You can use the API to confirm the date that an artifact is scheduled to be deleted. For more information, see the `expires_at` value returned by "[List artifacts for a repository](/rest/reference/actions#artifacts)."
{% endif %}
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
---
title: Using workflow run logs
intro: 'You can view, search, and download the logs for each job in a workflow run. {% data variables.product.product_name %} stores full build logs and artifacts for 90 days.'
intro: 'You can view, search, and download the logs for each job in a workflow run.'
product: '{% data reusables.gated-features.actions %}'
versions:
free-pro-team: '*'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,20 @@ Usage limits apply to self-hosted runners. For more information, see "[About sel
In addition to the usage limits, you must ensure that you use {% data variables.product.prodname_actions %} within the [GitHub Terms of Service](/articles/github-terms-of-service/). For more information on {% data variables.product.prodname_actions %}-specific terms, see the [GitHub Additional Product Terms](/github/site-policy/github-additional-product-terms#a-actions-usage).
{% endif %}

{% if currentVersion == "free-pro-team@latest" or currentVersion ver_gt "[email protected]" %}
### Artifact and log retention policy

You can configure the artifact and log retention period for your repository, organization, or enterprise account.

{% data reusables.actions.about-artifact-log-retention %}

For more information, see:

- [Configuring the retention period for {% data variables.product.prodname_actions %} for artifacts and logs in your repository](/github/administering-a-repository/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-repository)
- [Configuring the retention period for {% data variables.product.prodname_actions %} for artifacts and logs in your organization](/github/setting-up-and-managing-organizations-and-teams/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-organization)
- [Configuring the retention period for {% data variables.product.prodname_actions %} for artifacts and logs in your enterprise](/github/setting-up-and-managing-your-enterprise-account/configuring-the-retention-period-for-github-actions-artifacts-and-logs-in-your-enterprise-account)
{% endif %}

### Disabling or limiting {% data variables.product.prodname_actions %} for your repository or organization

{% data reusables.github-actions.disabling-github-actions %}
Expand Down
Loading

0 comments on commit 2294987

Please sign in to comment.