I've been struggling with this as well, so I solved it by using the GitHub Packages REST API to list the package versions and then extracting the tag from the first element in the respose using jq:
curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <github_token>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions | jq '[.[] ] | .[0] .metadata .container .tags[0]'
Answer from Nanor on Stack OverflowGitHub
docs.github.com › en › rest › packages
REST API endpoints for packages - GitHub Docs
Use the REST API to interact with GitHub Packages.
Home
Get started, troubleshoot, and make the most of GitHub. Documentation for new users, developers, administrators, and all of GitHub's products.
REST API
Create integrations, retrieve data, and automate your workflows with the GitHub REST API.
Quickstart
Learn how to get started with the GitHub REST API.
Authenticating
You can authenticate to the REST API to access more endpoints and have a higher rate limit.
Videos
18:26
Deploying ASP.NET API on Amazon EC2 Using GitHub Actions - YouTube
11:04
Mastering GitHub API with Node.js: Fetch Public & Private ...
04:10
GitHub API Tutorial | 2023 - YouTube
26:49
Building a REST API with GitHub Copilot: A beginner's guide - YouTube
01:28
GitHub: Getting Repository using REST API - YouTube
07:22
Exploring the GitHub REST API in 7' - YouTube
Top answer 1 of 2
1
I've been struggling with this as well, so I solved it by using the GitHub Packages REST API to list the package versions and then extracting the tag from the first element in the respose using jq:
curl -s \
-H "Accept: application/vnd.github+json" \
-H "Authorization: Bearer <github_token>" \
-H "X-GitHub-Api-Version: 2022-11-28" \
https://api.github.com/orgs/ORG/packages/PACKAGE_TYPE/PACKAGE_NAME/versions | jq '[.[] ] | .[0] .metadata .container .tags[0]'
2 of 2
0
Based on @Nanor answer, I've achieved it with gh cli tool:
gh api orgs/$ORG/packages/$PACKAGE_TYPE/$PACKAGE_NAME/versions | jq -r '.[0].name'
GitHub
docs.github.com › en › enterprise-server@3.10 › rest › packages › packages
REST API endpoints for packages - GitHub Enterprise Server 3.10 Docs
For more information, see "About permissions for GitHub Packages." This endpoint works with the following fine-grained token types: ... The fine-grained token does not require any permissions. ... curl -L \ -H "Accept: application/vnd.github+json" \ -H "Authorization: Bearer <YOUR-TOKEN>" \ -H "X-GitHub-Api-Version: 2022-11-28" \ "http(s)://HOSTNAME/api/v3/orgs/ORG/packages?package_type=container"
Stack Overflow
stackoverflow.com › questions › 78730515 › github-packages-manage-access-to-package-from-actions-using-api
GitHub Packages: Manage access to package from Actions using API? - Stack Overflow
steps: - name: Checkout code uses: actions/checkout@v2 - name: Configure npm for GitHub Packages run: | echo "//npm.pkg.github.com/:_authToken=${{ secrets.PAT }}" > ~/.npmrc - name: Install Dependencies run: npm install ... Sign up to request clarification or add additional context in comments. ... You can not add repos to the package access list via API.
GitHub
docs.github.com › en › enterprise-cloud@latest › packages › learn-github-packages › introduction-to-github-packages
Introduction to GitHub Packages - GitHub Enterprise Cloud Docs
You can integrate GitHub Packages with GitHub's APIs, GitHub Actions, and webhooks to create an end-to-end DevOps workflow that includes your code, CI, and deployment solutions.
GitHub
docs.github.com › en › rest
GitHub REST API documentation - GitHub Docs
Create integrations, retrieve data, and automate your workflows with the GitHub REST API.
GitHub
docs.github.com › en › packages › working-with-a-github-packages-registry › working-with-the-npm-registry
Working with the npm registry - GitHub Docs
You can use a personal access token (classic) to authenticate to GitHub Packages or the GitHub API. When you create a personal access token (classic), you can assign the token different scopes depending on your needs.
GitHub
docs.github.com › en › enterprise-server@3.10 › packages › learn-github-packages › introduction-to-github-packages
Introduction to GitHub Packages - GitHub Enterprise Server 3.10 Docs
You can integrate GitHub Packages with GitHub's APIs, GitHub Actions, and webhooks to create an end-to-end DevOps workflow that includes your code, CI, and deployment solutions.
GitHub
docs.github.com › en › packages
GitHub Packages documentation - GitHub Docs
GitHub Packages is a software package hosting service that allows you to host your software packages privately or publicly and use packages as dependencies in your projects.
GitHub
docs.github.com › en › packages › working-with-a-github-packages-registry › working-with-the-container-registry
Working with the Container registry - GitHub Docs
You can use a personal access token (classic) to authenticate to GitHub Packages or the GitHub API. When you create a personal access token (classic), you can assign the token different scopes depending on your needs.
npm
npmjs.com › package › github-api
github-api - npm
January 25, 2021 - A higher-level wrapper around the Github API.. Latest version: 3.4.0, last published: 5 years ago. Start using github-api in your project by running `npm i github-api`. There are 182 other projects in the npm registry using github-api.
» npm install github-api
GitHub
github.com › orgs › community › discussions › 45560
API access to GitHub container settings for action access · community · Discussion #45560
January 27, 2023 - Remember you could be rate limited by Github API. If you have 300 to do. Beta Was this translation helpful? Give feedback. ... There was an error while loading. Please reload this page. Something went wrong. There was an error while loading. Please reload this page. ... @jge162 You seem to be talking about the solution, but it isn't in the documentation. If I try to hit · gh api -X POST /orgs/{org}/packages/container/{package_name}/settings/add_actions_access { "message": "Not Found", "documentation_url": "https://docs.github.com/enterprise-server@3.12/rest" } gh: Not Found (HTTP 404)
GitHub
docs.github.com › en › packages › working-with-a-github-packages-registry › working-with-the-nuget-registry
Working with the NuGet registry - GitHub Docs
Replace PROJECT_NAME with the name of the project, 1.0.0 with the version number of the package, and YOUR_GITHUB_PAT with your personal access token. dotnet nuget push "bin/Release/PROJECT_NAME.1.0.0.nupkg" --api-key YOUR_GITHUB_PAT --source "github"
GitHub
docs.github.com › en › packages › working-with-a-github-packages-registry › working-with-the-apache-maven-registry
Working with the Apache Maven registry - GitHub Docs
You can use a personal access token (classic) to authenticate to GitHub Packages or the GitHub API. When you create a personal access token (classic), you can assign the token different scopes depending on your needs.