Skip to content

Commit e8d06f4

Browse files
committed
feat: add local-workflow-actions action
Signed-off-by: Emilien Escalle <emilien.escalle@escemi.com>
1 parent cdf2bbe commit e8d06f4

2 files changed

Lines changed: 174 additions & 0 deletions

File tree

Lines changed: 113 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,113 @@
1+
<!-- header:start -->
2+
3+
# ![Icon](data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIyNCIgaGVpZ2h0PSIyNCIgdmlld0JveD0iMCAwIDI0IDI0IiBmaWxsPSJub25lIiBzdHJva2U9ImN1cnJlbnRDb2xvciIgc3Ryb2tlLXdpZHRoPSIyIiBzdHJva2UtbGluZWNhcD0icm91bmQiIHN0cm9rZS1saW5lam9pbj0icm91bmQiIGNsYXNzPSJmZWF0aGVyIGZlYXRoZXItZG93bmxvYWQiIGNvbG9yPSJibHVlIj48cG9seWxpbmUgcG9pbnRzPSIxNiAyIDggMTIgMTYgMjIiPjwvcG9seWxpbmU+PHBhdGggZD0iTTggMjJoMTYiPjwvcGF0aD48cGF0aCBkPSJNNCAyMmg0Ij48L3BhdGg+PC9zdmc+) GitHub Action: Local workflow actions
4+
5+
<div align="center">
6+
<img src="../../.github/logo.svg" width="60px" align="center" alt="Local workflow actions" />
7+
</div>
8+
9+
---
10+
11+
<!-- header:end -->
12+
13+
<!-- badges:start -->
14+
15+
[![Marketplace](https://img.shields.io/badge/Marketplace-local--workflow--actions-blue?logo=github-actions)](https://github.com/marketplace?type=actions&query=hoverkraft-tech+local-workflow-actions)
16+
[![Release](https://img.shields.io/github/v/release/hoverkraft-tech/ci-github-common)](https://github.com/hoverkraft-tech/ci-github-common/releases)
17+
[![License](https://img.shields.io/github/license/hoverkraft-tech/ci-github-common)](http://choosealicense.com/licenses/mit/)
18+
[![Stars](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-common?style=social)](https://img.shields.io/github/stars/hoverkraft-tech/ci-github-common?style=social)
19+
[![PRs Welcome](https://img.shields.io/badge/PRs-welcome-brightgreen.svg)](https://github.com/hoverkraft-tech/ci-github-common/blob/main/CONTRIBUTING.md)
20+
21+
<!-- badges:end -->
22+
23+
<!-- overview:start -->
24+
25+
## Overview
26+
27+
This action checks out the reusable workflow repository that triggered the current run and copies its local actions directory (default `.github/actions`) into the current workspace. It runs both during the main step and in the post step so that actions with cleanup hooks are also available.
28+
29+
Use it when consuming reusable workflows that reference local actions from the same repository—they are not automatically available in the caller repository and must be synced manually.
30+
31+
<!-- overview:end -->
32+
33+
<!-- usage:start -->
34+
35+
## Usage
36+
37+
```yaml
38+
- name: Sync workflow-local actions
39+
uses: hoverkraft-tech/ci-github-common/actions/local-workflow-actions@5e8d0e6d1e76d8577a070db6d0128a91b1c9d5ad # 0.30.2
40+
with:
41+
# Optional path (relative to the workflow repository) that contains the local actions.
42+
# The same relative path will be created inside the current workspace.
43+
#
44+
# Default: `.github/actions`
45+
actions-path: .github/actions
46+
47+
# Token used to download the workflow repository.
48+
# Default: ${{ github.token }}
49+
github-token: ${{ secrets.GITHUB_TOKEN }}
50+
```
51+
52+
<!-- usage:end -->
53+
54+
<!-- inputs:start -->
55+
56+
## Inputs
57+
58+
| **Input** | **Description** | **Required** | **Default** |
59+
| ------------------ | --------------------------------------------------------------------------------------------------------------------------------------------------------- | ------------ | --------------------- |
60+
| **`actions-path`** | Relative path (inside the workflow repository) containing the local actions. The same relative path will be created inside the current workspace. | **false** | `.github/actions` |
61+
| **`github-token`** | Token used to fetch the workflow repository. Defaults to `github.token`, which is sufficient for public repos and needs `contents:read` for private ones. | **false** | `${{ github.token }}` |
62+
63+
<!-- inputs:end -->
64+
65+
<!-- secrets:start -->
66+
<!-- secrets:end -->
67+
68+
<!-- outputs:start -->
69+
<!-- outputs:end -->
70+
71+
<!-- examples:start -->
72+
<!-- examples:end -->
73+
74+
<!--
75+
// jscpd:ignore-start
76+
-->
77+
78+
<!-- contributing:start -->
79+
80+
## Contributing
81+
82+
Contributions are welcome! Please see the [contributing guidelines](https://github.com/hoverkraft-tech/ci-github-common/blob/main/CONTRIBUTING.md) for more details.
83+
84+
<!-- contributing:end -->
85+
86+
<!-- security:start -->
87+
<!-- security:end -->
88+
89+
<!-- license:start -->
90+
91+
## License
92+
93+
This project is licensed under the MIT License.
94+
95+
SPDX-License-Identifier: MIT
96+
97+
Copyright © 2025 hoverkraft
98+
99+
For more details, see the [license](http://choosealicense.com/licenses/mit/).
100+
101+
<!-- license:end -->
102+
103+
<!-- generated:start -->
104+
105+
---
106+
107+
This documentation was automatically generated by [CI Dokumentor](https://github.com/hoverkraft-tech/ci-dokumentor).
108+
109+
<!-- generated:end -->
110+
111+
<!--
112+
// jscpd:ignore-end
113+
-->
Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
name: "Local workflow actions"
2+
description: |
3+
This action checks out the reusable workflow repository that triggered the current run and copies its local actions directory into the current workspace.
4+
It runs both during the main step and in the post step so that actions with cleanup hooks are also available.
5+
Use it when consuming reusable workflows that reference local actions from the same repository—they are not automatically available in the caller repository and must be synced manually.
6+
7+
Local actions will be available at `./<local-path>/<actions-path>` inside the current workspace.
8+
Example: if `local-path` is `./self-workflow` and `actions-path` is `.github/actions`, then local actions will be available at `./self-workflow/.github/actions`.
9+
10+
author: hoverkraft
11+
branding:
12+
icon: download
13+
color: blue
14+
15+
inputs:
16+
actions-path:
17+
description: |
18+
Relative path(s) (inside the workflow repository) containing the local actions to expose in the current workspace.
19+
The same relative path will be used inside the current workspace (for example `.github/actions`).
20+
required: false
21+
default: ".github/actions"
22+
local-path:
23+
description: |
24+
Path inside the current workspace where to copy the local actions from the reusable workflow repository.
25+
required: false
26+
default: "./self-workflow"
27+
repository:
28+
description: |
29+
The reusable workflow repository that triggered the current run, in the format `owner/repo`.
30+
If not provided, this is automatically filled by the OIDC action.
31+
required: false
32+
ref:
33+
description: |
34+
The git ref (branch, tag, or SHA) of the reusable workflow repository that triggered the current run.
35+
If not provided, this is automatically filled by the OIDC action.
36+
required: false
37+
38+
outputs:
39+
repository:
40+
description: The reusable workflow repository that was checked out, in the format `owner/repo`.
41+
value: ${{ inputs.repository || steps.oidc.outputs.job_workflow_repo_name_and_owner }}
42+
ref:
43+
description: The git ref (branch, tag, or SHA) of the reusable workflow repository that was checked out.
44+
value: ${{ inputs.ref || steps.oidc.outputs.job_workflow_repo_ref }}
45+
46+
runs:
47+
using: "composite"
48+
steps:
49+
# FIXME: This is a workaround for having workflow actions. See https://github.com/orgs/community/discussions/38659
50+
- id: oidc
51+
if: ${{ inputs.repository == '' }}
52+
uses: ChristopherHX/oidc@73eee1ff03fdfce10eda179f617131532209edbd # v3
53+
54+
- uses: actions/checkout@1af3b93b6815bc44a9784bd300feb67ff0d1eeb3 # v6.0.0
55+
with:
56+
persist-credentials: false
57+
path: ${{ inputs.local-path }}
58+
repository: ${{ inputs.repository || steps.oidc.outputs.job_workflow_repo_name_and_owner }}
59+
ref: ${{ inputs.ref || steps.oidc.outputs.job_workflow_repo_ref }}
60+
sparse-checkout: |
61+
${{ inputs.actions-path }}

0 commit comments

Comments
 (0)