-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Created action for listing packages with their tags for an organizati…
…on (#1) * Created action for listing packages with their tags for an organization * Disabled linter for dist/index.js file * Disable the linter for dist/index.js file for resolving errors * Resolved linting errors * Testing the github action * Created a token for testing * Updated dist/index.js file
- Loading branch information
1 parent
d6b483f
commit f0274bf
Showing
8 changed files
with
4,458 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
name: TestCase 1 - Testing the working of action | ||
on: | ||
push: | ||
branches: | ||
- "list-packages-with-tags" # Enter the branch you want to test | ||
|
||
jobs: | ||
run-action: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout repository (clone the repo for use) | ||
uses: actions/checkout@v3 | ||
- uses: Calance-US/calance-list-packages-with-tags-action@list-packages-with-tags | ||
id: list-packages-with-tags | ||
with: | ||
image_name: calance-workflows | ||
package_type: container | ||
organization: Calance-US | ||
GET_PACKAGES_TOKEN: ${{ secrets.GET_PACKAGES_TOKEN }} | ||
- name: Echo the outputs | ||
run: | | ||
echo ${{ steps.list-packages-with-tags.outputs.packages-with-tags }} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
node_modules |
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
name: List packages with tags | ||
description: List packages with tags | ||
|
||
inputs: | ||
image_name: | ||
description: Image Names in CSV format | ||
required: true | ||
package_type: | ||
description: Enter the package type (Options are container,docker,npm etc.) | ||
required: true | ||
organization: | ||
description: Enter the name of organization | ||
required: true | ||
GET_PACKAGES_TOKEN: | ||
description: Github token with permissions - read:packages | ||
required: true | ||
|
||
outputs: | ||
packages-with-tags: | ||
description: Packages with their tags | ||
|
||
runs: | ||
using: 'node16' | ||
main: 'dist/index.js' |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
const core = require('@actions/core') | ||
const Github = require('@actions/github') | ||
|
||
const listPackagesWithTags = async () => { | ||
try { | ||
const versionedPackages = [] | ||
let packagesArray = core.getInput('image_name', { required: true }) | ||
packagesArray = packagesArray.split(',').map(x => x.trim()) | ||
const token = core.getInput('GET_PACKAGES_TOKEN', { required: true }) | ||
const github = Github.getOctokit(token) | ||
const packageType = core.getInput('package_type', { required: true }) | ||
const organization = core.getInput('organization', { required: true }) | ||
|
||
for (let i = 0; i < packagesArray.length; i++) { | ||
const resp1 = await github.request('GET /orgs/{organization}/packages/{packageType}/{packageName}/versions', { | ||
packageName: packagesArray[i], | ||
packageType, | ||
organization | ||
}) | ||
const resp2 = resp1.data.map(data => data.metadata) | ||
for (let j = 0; j < resp2.length; j++) { | ||
const tags = resp2[j].container.tags | ||
if (tags === []) { | ||
continue | ||
} else { | ||
for (let k = 0; k < tags.length; k++) { | ||
versionedPackages.push(packagesArray[i].concat(':', tags[k])) | ||
} | ||
} | ||
} | ||
} | ||
console.log(versionedPackages) | ||
core.setOutput('packages-with-tags', versionedPackages) | ||
} catch (error) { | ||
core.setFailed(error.message) | ||
} | ||
} | ||
listPackagesWithTags() |
Oops, something went wrong.