Using GitHub Packages with GitHub Actions

You can configure a workflow in GitHub Actions to automatically publish or install a package from GitHub Packages.

GitHub Packages is available with GitHub Free, GitHub Pro, GitHub Team, and GitHub Enterprise Cloud. GitHub Packages is unavailable for per-repository plans, which are legacy billing plans. For more information, see "GitHub's products."

In this article

About GitHub Packages with GitHub Actions

GitHub Actions help you automate your software development workflows in the same place you store code and collaborate on pull requests and issues. You can write individual tasks, called actions, and combine them to create a custom workflow. With GitHub Actions you can build end-to-end continuous integration (CI) and continuous deployment (CD) capabilities directly in your repository. For more information, see "About GitHub Actions."

You can extend the CI and CD capabilities of your repository by publishing or installing packages as part of your workflow. Instead of using a personal access token to authenticate to GitHub Packages, use the GITHUB_TOKEN that GitHub automatically creates for your repository when you enable GitHub Actions. The GITHUB_TOKEN has read:packages and write:packages scopes to the current repository. For forks, the token also has the read:packages scope for the parent repository.

You can reference the GITHUB_TOKEN in your workflow file using the {{secrets.GITHUB_TOKEN}} context. For more information, see "Authenticating with the GITHUB_TOKEN."

Publishing a package using an action

You can publish packages as part of your continuous integration (CI) flow using GitHub Actions. For example, you could configure a workflow so that anytime a developer pushes code to master, the workflow runs CI tests. If those tests pass, the workflow publishes a new package version to GitHub Packages. This workflow automates the creation of new package versions only if the code meets your quality standards.

Configuration steps vary by package client. For general information about configuring a workflow for GitHub Actions, see "Configuring a workflow."

Installing a package using an action

You can install packages as part of your CI flow using GitHub Actions. For example, you could configure a workflow so that anytime a developer pushes code to a pull request, the workflow resolves dependencies by downloading and installing packages hosted by GitHub Packages. Then, the workflow can run CI tests that require the dependencies.

Installing packages hosted by GitHub Packages through GitHub Actions requires minimal configuration or additional authentication, by using the GITHUB_TOKEN. Data transfer is also free when an action installs a package. For more information, see "About billing for GitHub Packages."

Configuration steps vary by package client. For general information about configuring a workflow for GitHub Actions, see "Configuring a workflow."

Ask a human

Can't find what you're looking for?

Contact us