{"id":13529401,"url":"https://github.com/actions/container-toolkit-action","last_synced_at":"2025-04-04T23:09:23.918Z","repository":{"id":56505419,"uuid":"200097436","full_name":"actions/container-toolkit-action","owner":"actions","description":"Template repo for creating container actions using https://github.com/actions/toolkit/","archived":false,"fork":false,"pushed_at":"2025-03-25T15:15:24.000Z","size":3889,"stargazers_count":134,"open_issues_count":0,"forks_count":26,"subscribers_count":8,"default_branch":"main","last_synced_at":"2025-03-28T22:14:24.503Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"TypeScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/actions.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":"CODEOWNERS","security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2019-08-01T18:04:10.000Z","updated_at":"2025-03-26T10:29:14.000Z","dependencies_parsed_at":"2023-11-07T15:31:31.526Z","dependency_job_id":"d0bd70d3-0555-4b56-9dde-7389e3c21fde","html_url":"https://github.com/actions/container-toolkit-action","commit_stats":{"total_commits":108,"total_committers":6,"mean_commits":18.0,"dds":0.4629629629629629,"last_synced_commit":"86b4a4652c2edc7a5134cc333658499f9d012989"},"previous_names":[],"tags_count":0,"template":true,"template_full_name":"actions/container-action","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actions%2Fcontainer-toolkit-action","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actions%2Fcontainer-toolkit-action/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actions%2Fcontainer-toolkit-action/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/actions%2Fcontainer-toolkit-action/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/actions","download_url":"https://codeload.github.com/actions/container-toolkit-action/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247261612,"owners_count":20910108,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-08-01T07:00:35.976Z","updated_at":"2025-04-04T23:09:23.894Z","avatar_url":"https://github.com/actions.png","language":"TypeScript","funding_links":[],"categories":["HarmonyOS","Official Resources","TypeScript"],"sub_categories":["Windows Manager","Create your Actions"],"readme":"# Create a Container Action with the GitHub Actions Toolkit\n\n[![GitHub Super-Linter](https://github.com/actions/container-toolkit-action/actions/workflows/linter.yml/badge.svg)](https://github.com/super-linter/super-linter)\n![Check `dist/`](https://github.com/actions/container-toolkit-action/actions/workflows/check-dist.yml/badge.svg)\n![CI](https://github.com/actions/container-toolkit-action/actions/workflows/ci.yml/badge.svg)\n[![Code Coverage](./badges/coverage.svg)](./badges/coverage.svg)\n\nUse this template to bootstrap the creation of a container action with the\nGitHub Actions toolkit. :rocket:\n\nThis template includes compilation support, tests, a validation workflow,\npublishing, and versioning guidance.\n\nFor more information on the GitHub Actions toolkit, see the\n[`actions/toolkit` repository](https://github.com/actions/toolkit/tree/main/docs)\n\n## Create Your Own Action\n\nTo create your own action, you can use this repository as a template! Just\nfollow the below instructions:\n\n1. Click the **Use this template** button at the top of the repository\n1. Select **Create a new repository**\n1. Select an owner and name for your new repository\n1. Click **Create repository**\n1. Clone your new repository\n\n\u003e [!IMPORTANT]\n\u003e\n\u003e Make sure to remove or update the [`CODEOWNERS`](./CODEOWNERS) file! For\n\u003e details on how to use this file, see\n\u003e [About code owners](https://docs.github.com/en/repositories/managing-your-repositorys-settings-and-features/customizing-your-repository/about-code-owners).\n\n## Initial Setup\n\nAfter you've cloned the repository to your local machine or codespace, you'll\nneed to perform some initial setup steps before you can develop your action.\n\n\u003e [!NOTE]\n\u003e\n\u003e You'll need to have reasonably modern versions of\n\u003e [Node.js](https://nodejs.org) and\n\u003e [Docker](https://www.docker.com/get-started/) handy (e.g. Node.js v20+ and\n\u003e docker engine v20+).\n\n1. :hammer_and_wrench: Install the dependencies\n\n   ```bash\n   npm install\n   ```\n\n1. :building_construction: Package the TypeScript for distribution\n\n   ```bash\n   npm run bundle\n   ```\n\n1. :white_check_mark: Run the tests\n\n   ```bash\n   $ npm test\n\n   PASS  ./index.test.js\n     ✓ throws invalid number (3ms)\n     ✓ wait 500 ms (504ms)\n     ✓ test runs (95ms)\n\n   ...\n   ```\n\n1. :hammer_and_wrench: Build the container\n\n   Make sure to replace `actions/container-toolkit-action` with an appropriate\n   label for your container.\n\n   ```bash\n   docker build -t actions/container-toolkit-action .\n   ```\n\n1. :white_check_mark: Test the container\n\n   You can pass individual environment variables using the `--env` or `-e` flag.\n\n   ```bash\n   $ docker run --env INPUT_MILLISECONDS=2000 actions/container-toolkit-action\n   ::debug::The event payload: {}\n   16:19:19 GMT+0000 (Coordinated Universal Time)\n   16:19:21 GMT+0000 (Coordinated Universal Time)\n\n   ::set-output name=time::16:19:21 GMT+0000 (Coordinated Universal Time)\n   ```\n\n   Or you can pass a file with environment variables using `--env-file`.\n\n   ```bash\n   $ echo \"INPUT_MILLISECONDS=2000\" \u003e ./.env.test\n\n   $ docker run --env-file ./.env.test actions/container-toolkit-action\n   ::debug::The event payload: {}\n   16:19:19 GMT+0000 (Coordinated Universal Time)\n   16:19:21 GMT+0000 (Coordinated Universal Time)\n\n   ::set-output name=time::16:19:21 GMT+0000 (Coordinated Universal Time)\n   ```\n\n## Update the Action Metadata\n\nThe [`action.yml`](action.yml) file defines metadata about your action, such as\ninput(s) and output(s). For details about this file, see\n[Metadata syntax for GitHub Actions](https://docs.github.com/en/actions/creating-actions/metadata-syntax-for-github-actions).\n\nWhen you copy this repository, update `action.yml` with the name, description,\ninputs, and outputs for your action.\n\n## Update the Action Code\n\n### Update the TypeScript Source\n\nThe [`src/`](./src/) directory is the heart of your action! This contains the\nsource code that will be run when your action is invoked. You can replace the\ncontents of this directory with your own code.\n\nThere are a few things to keep in mind when writing your action code:\n\n- Most GitHub Actions toolkit and CI/CD operations are processed asynchronously.\n  In `main.ts`, you will see that the action is run in an `async` function.\n\n  ```javascript\n  import * as core from '@actions/core'\n  //...\n\n  export async function run(): Promise\u003cvoid\u003e {\n    try {\n      //...\n    } catch (error) {\n      core.setFailed(error.message)\n    }\n  }\n  ```\n\n  For more information about the GitHub Actions toolkit, see the\n  [documentation](https://github.com/actions/toolkit/blob/main/README.md).\n\n### Update the Container\n\nIn this template, the container action runs a Node.js script,\n`node /dist/index.js`, when the container is launched. Since you can choose any\nbase Docker image and language you like, you can change this to suite your\nneeds. There are a few main things to remember when writing code for container\nactions:\n\n- Inputs are accessed using argument identifiers or environment variables\n  (depending on what you set in your `action.yml`). For example, the first input\n  to this action, `milliseconds`, can be accessed in the Node.js script using\n  the `process.env.INPUT_MILLISECONDS` environment variable or the\n  `getInput('milliseconds')` function from the `@actions/core` library.\n\n  ```bash\n  // Use an action input\n  const ms: number = parseInt(core.getInput('milliseconds'), 10)\n\n  // Use an environment variable\n  const ms: number = parseInt(process.env.INPUT_MILLISECONDS, 10)\n  ```\n\n- GitHub Actions supports a number of different workflow commands such as\n  creating outputs, setting environment variables, and more. These are\n  accomplished by writing to different `GITHUB_*` environment variables. For\n  more information, see\n  [Commands](https://github.com/actions/toolkit/blob/main/docs/commands.md).\n\n  | Scenario             | Example                                             |\n  | -------------------- | --------------------------------------------------- |\n  | Set environment vars | `core.exportVariable('MY_VAR', 'my-value')`         |\n  | Set outputs          | `core.setOutput('time', new Date().toTimeString())` |\n  | Set secrets          | `core.setSecret('mySecret')`                        |\n  | Prepend to `PATH`    | `core.addPath('/usr/local/bin')`                    |\n\n## Publish the Action\n\nSo, what are you waiting for? Go ahead and start customizing your action!\n\n1. Create a new branch\n\n   ```bash\n   git checkout -b releases/v1\n   ```\n\n1. Replace the contents of `src/` with your action code\n1. Add tests to `__tests__/` for your source code\n1. Format, test, and build the action\n\n   ```bash\n   npm run all\n   ```\n\n   \u003e [!WARNING]\n   \u003e\n   \u003e This step is important! It will run [`ncc`](https://github.com/vercel/ncc)\n   \u003e to build the final JavaScript action code with all dependencies included.\n   \u003e If you do not run this step, your action will not work correctly when it is\n   \u003e used in a workflow. This step also includes the `--license` option for\n   \u003e `ncc`, which will create a license file for all of the production node\n   \u003e modules used in your project.\n\n1. Commit your changes\n\n   ```bash\n   git add .\n   git commit -m \"My first action is ready!\"\n   ```\n\n1. Push them to your repository\n\n   ```bash\n   git push -u origin releases/v1\n   ```\n\n1. Create a pull request and get feedback on your action\n1. Merge the pull request into the `main` branch\n\nYour action is now published! :rocket:\n\nFor information about versioning your action, see\n[Versioning](https://github.com/actions/toolkit/blob/master/docs/action-versioning.md)\nin the GitHub Actions toolkit.\n\n## Validate the Action\n\nYou can now validate the action by referencing it in a workflow file. For\nexample, [`ci.yml`](./.github/workflows/ci.yml) demonstrates how to reference an\naction in the same repository.\n\n```yaml\nsteps:\n  - name: Checkout\n    id: checkout\n    uses: actions/checkout@v4\n\n  - name: Test Local Action\n    id: test-action\n    uses: ./\n    with:\n      milliseconds: 1000\n\n  - name: Print Output\n    id: output\n    run: echo \"${{ steps.test-action.outputs.time }}\"\n```\n\nFor example workflow runs, check out the\n[Actions tab](https://github.com/actions/container-toolkit-action/actions)!\n:rocket:\n\n## Usage\n\nAfter testing, you can create version tag(s) that developers can use to\nreference different stable versions of your action. For more information, see\n[Versioning](https://github.com/actions/toolkit/blob/main/docs/action-versioning.md)\nin the GitHub Actions toolkit.\n\nTo include the action in a workflow in another repository, you can use the\n`uses` syntax with the `@` symbol to reference a specific branch, tag, or commit\nhash.\n\n```yaml\nsteps:\n  - name: Checkout\n    id: checkout\n    uses: actions/checkout@v4\n\n  - name: Test Local Action\n    id: test-action\n    uses: actions/container-toolkit-action@v1 # Commit with the `v1` tag\n    with:\n      milliseconds: 1000\n\n  - name: Print Output\n    id: output\n    run: echo \"${{ steps.test-action.outputs.time }}\"\n```\n\n## Dependency License Management\n\nThis template includes a GitHub Actions workflow,\n[`licensed.yml`](./.github/workflows/licensed.yml), that uses\n[Licensed](https://github.com/licensee/licensed) to check for dependencies with\nmissing or non-compliant licenses. This workflow is initially disabled. To\nenable the workflow, follow the below steps.\n\n1. Open [`licensed.yml`](./.github/workflows/licensed.yml)\n1. Uncomment the following lines:\n\n   ```yaml\n   # pull_request:\n   #   branches:\n   #     - main\n   # push:\n   #   branches:\n   #     - main\n   ```\n\n1. Save and commit the changes\n\nOnce complete, this workflow will run any time a pull request is created or\nchanges pushed directly to `main`. If the workflow detects any dependencies with\nmissing or non-compliant licenses, it will fail the workflow and provide details\non the issue(s) found.\n\n### Updating Licenses\n\nWhenever you install or update dependencies, you can use the Licensed CLI to\nupdate the licenses database. To install Licensed, see the project's\n[Readme](https://github.com/licensee/licensed?tab=readme-ov-file#installation).\n\nTo update the cached licenses, run the following command:\n\n```bash\nlicensed cache\n```\n\nTo check the status of cached licenses, run the following command:\n\n```bash\nlicensed status\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factions%2Fcontainer-toolkit-action","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Factions%2Fcontainer-toolkit-action","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Factions%2Fcontainer-toolkit-action/lists"}