Files

61 lines
2.8 KiB
Markdown
Raw Permalink Normal View History

2024-07-30 16:56:30 +01:00
# Publish Immutable Action
2023-11-17 20:04:42 +00:00
2024-07-30 16:36:28 +01:00
> [!IMPORTANT]
> This action is **not ready for public use**. It is part of an upcoming public roadmap item (see [GitHub Actions: Immutable actions publishing](https://github.com/github/roadmap/issues/592)).
> Attempts to use this action to upload an OCI artifact will not work until this feature has been fully released to the public. Please do not attempt to use it until that time.
2024-07-30 17:12:06 +01:00
This action packages _your action_ as an [OCI container](https://opencontainers.org/) and publishes it to the [GitHub Container registry](https://ghcr.io).
2024-07-30 17:03:18 +01:00
This allows your action to be consumed as an _immutable_ package if a [SemVer](https://semver.org/) is specified in the consumer's workflow file.
2023-11-17 20:04:42 +00:00
2024-08-10 10:56:12 +01:00
Your workflow can be triggered by any [event](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows) which has a `GITHUB_REF` that points to a Git tag.
2024-07-30 17:20:03 +01:00
Some examples of these events are:
2024-07-30 17:12:06 +01:00
2024-07-30 17:48:02 +01:00
- [`release`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#release) (uses tag associated with release)
2024-07-30 17:12:06 +01:00
- [`push`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#push) (only applies to pushed tags)
2024-07-30 17:48:02 +01:00
- [`workflow_dispatch`](https://docs.github.com/en/actions/using-workflows/events-that-trigger-workflows#workflow_dispatch) (only applies if subject of dispatch is a tag)
2024-07-30 17:12:06 +01:00
2024-07-30 16:56:30 +01:00
The associated tag must follow [semantic versioning](https://semver.org/) - this tag value will be used to create a package version.
2023-11-17 20:04:42 +00:00
2024-07-30 16:56:30 +01:00
Consumers of your action will then be able to specify that version to consume your action from the package, e.g.
2024-07-30 16:36:28 +01:00
2024-07-30 16:56:30 +01:00
- `- uses: your-name/your-action@v1.2.3`
- `- uses: your-name/your-action@v1`
2024-07-30 15:33:26 +01:00
2024-07-30 16:56:30 +01:00
Such packages will come with stronger security guarantees for consumers than existing git-based action resolution, such as:
2024-07-30 16:48:33 +01:00
2024-07-30 16:56:30 +01:00
- Provenance attestations generated using the [`@actions/attest`](https://github.com/actions/toolkit/tree/main/packages/attest) package
- Tag immutability - it will not be possible to overwrite tags once published, ensuring versions of an action can't change once in use
- Namespace immutability - it will not be possible to delete and recreate the package with different content; this would undermine tag immutability
2023-11-17 20:04:42 +00:00
2023-11-17 21:31:12 +00:00
## Usage
2023-11-17 20:04:42 +00:00
2024-07-30 16:56:30 +01:00
An actions workflow file like the following should be placed in your action repository:
2024-07-30 16:48:33 +01:00
2023-11-17 20:04:42 +00:00
<!-- start usage -->
```yaml
2024-07-30 17:48:02 +01:00
name: "Publish Immutable Action Version"
2024-07-30 16:48:33 +01:00
2023-11-17 20:04:42 +00:00
on:
release:
2024-09-16 17:05:18 +02:00
types: [published]
2024-07-30 16:48:33 +01:00
jobs:
publish:
runs-on: ubuntu-latest
permissions:
2024-08-12 10:17:43 +01:00
contents: read
2024-07-30 16:48:33 +01:00
id-token: write
packages: write
steps:
- name: Check out repo
uses: actions/checkout@v4
- name: Publish
id: publish
2024-09-16 16:23:45 +02:00
uses: actions/publish-immutable-action@0.0.3
2023-11-17 20:04:42 +00:00
```
<!-- end usage -->
2023-11-17 21:31:12 +00:00
## License
2023-11-17 20:04:42 +00:00
2024-01-23 15:24:45 -05:00
The scripts and documentation in this project are released under the [MIT License](LICENSE).