Skip to content

Commit d4235ea

Browse files
authored
Merge pull request #63 from gulfofmaine/claude/self-repo-syntax-simplify-klgz23
Use self-repository syntax for composite actions
2 parents 1f818cc + 4b9617e commit d4235ea

11 files changed

Lines changed: 96 additions & 124 deletions

File tree

.github/actions/bump_images/action.yml

Lines changed: 5 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,6 @@
1010
# Prerequisites:
1111
# - The deploy repo is checked out, with credentials that can push unless
1212
# stage_only is "true".
13-
# - The `odp-releaser` CLI is on the PATH — run the sibling `install`
14-
# action first. (A composite action cannot reference a sibling local
15-
# action itself: relative `uses:` paths resolve against the workflow's
16-
# workspace, not the action's repo — see actions/runner#1348.)
1713
# - Only when the image manifest asks for a sync (`deployed_as` with
1814
# `sync: true`): `skopeo` on the PATH — preinstalled on GitHub-hosted
1915
# ubuntu runners — and the destination registry already logged in to by
@@ -26,9 +22,6 @@
2622
#
2723
# Minimal caller example:
2824
#
29-
# - name: Install ODP Releaser
30-
# uses: gulfofmaine/odp-releaser/.github/actions/install@<sha-or-tag>
31-
#
3225
# - name: Bump images
3326
# id: bump
3427
# uses: gulfofmaine/odp-releaser/.github/actions/bump_images@<sha-or-tag>
@@ -214,6 +207,11 @@ outputs:
214207
runs:
215208
using: composite
216209
steps:
210+
- name: Install ODP Releaser
211+
uses: $/.github/actions/install
212+
with:
213+
cache_suffix: odp-releaser-${{ github.action_ref }}
214+
217215
- name: Bump images
218216
id: bump
219217
shell: bash
@@ -228,11 +226,6 @@ runs:
228226
REPORTER_APP_ID: ${{ inputs.reporter_app_id }}
229227
REPORTER_APP_PRIVATE_KEY: ${{ inputs.reporter_app_private_key }}
230228
run: |
231-
if ! command -v odp-releaser >/dev/null; then
232-
echo "::error::odp-releaser CLI not found on the PATH; run the" \
233-
"gulfofmaine/odp-releaser/.github/actions/install action first"
234-
exit 1
235-
fi
236229
case "$VERBOSITY" in
237230
0) FLAGS=() ;;
238231
1) FLAGS=(-v) ;;
@@ -250,10 +243,6 @@ runs:
250243
# unlike the deployment report and the source-PR comment (both
251244
# continue-on-error, both cosmetic) a failed sync has to fail the bump —
252245
# which only helps if it runs before the commit or pull request lands.
253-
#
254-
# Inlined here rather than in a sibling `sync_image` action because a
255-
# composite action cannot `uses:` one (see the note at the top of this
256-
# file), and the ordering above is the whole point.
257246
- name: Sync image to the deploy registries
258247
id: sync
259248
if:

.github/actions/comment_on_pr/action.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,19 +15,12 @@
1515
# safe to run on any closed PR.
1616
#
1717
# Prerequisites:
18-
# - The `odp-releaser` CLI is on the PATH — run the sibling `install`
19-
# action first. (A composite action cannot reference a sibling local
20-
# action itself: relative `uses:` paths resolve against the workflow's
21-
# workspace, not the action's repo — see actions/runner#1348.)
2218
# - Reporter app credentials for the source org, whose app has been granted
2319
# `Pull requests: Read and write` — and whose existing installations have
2420
# accepted that permission. See the GitHub Apps docs.
2521
#
2622
# Minimal caller example:
2723
#
28-
# - name: Install ODP Releaser
29-
# uses: gulfofmaine/odp-releaser/.github/actions/install@<sha-or-tag>
30-
#
3124
# - name: Comment on the source pull request
3225
# uses: gulfofmaine/odp-releaser/.github/actions/comment_on_pr@<sha-or-tag>
3326
# with:
@@ -143,6 +136,11 @@ inputs:
143136
runs:
144137
using: composite
145138
steps:
139+
- name: Install ODP Releaser
140+
uses: $/.github/actions/install
141+
with:
142+
cache_suffix: odp-releaser-${{ github.action_ref }}
143+
146144
- name: Comment on source pull request
147145
shell: bash
148146
env:
@@ -162,11 +160,6 @@ runs:
162160
REPORTER_APP_ID: ${{ inputs.reporter_app_id }}
163161
REPORTER_APP_PRIVATE_KEY: ${{ inputs.reporter_app_private_key }}
164162
run: |
165-
if ! command -v odp-releaser >/dev/null; then
166-
echo "::error::odp-releaser CLI not found on the PATH; run the" \
167-
"gulfofmaine/odp-releaser/.github/actions/install action first"
168-
exit 1
169-
fi
170163
case "$VERBOSITY" in
171164
0) FLAGS=() ;;
172165
1) FLAGS=(-v) ;;

.github/actions/install/action.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,10 @@
55
# reference is enough to pin the CLI too, with no separate version input to
66
# keep in sync.
77
#
8+
# Optional: the other actions here run it themselves. It is a no-op when the
9+
# CLI is already on the PATH, so first install wins — pin it and its siblings
10+
# to the same ref.
11+
#
812
# Minimal caller example:
913
#
1014
# - name: Install ODP Releaser
@@ -34,8 +38,18 @@ inputs:
3438
runs:
3539
using: composite
3640
steps:
41+
- name: Check for an existing install
42+
id: check
43+
shell: bash
44+
run: |
45+
if command -v odp-releaser >/dev/null; then
46+
echo "installed=true" >> "$GITHUB_OUTPUT"
47+
else
48+
echo "installed=false" >> "$GITHUB_OUTPUT"
49+
fi
50+
3751
- name: Set up uv
38-
if: inputs.install_uv == 'true'
52+
if: inputs.install_uv == 'true' && steps.check.outputs.installed != 'true'
3953
uses: astral-sh/setup-uv@c771a70e6277c0a99b617c7a806ffedaca235ff9 # v9.0.0
4054
with:
4155
enable-cache: true
@@ -47,5 +61,6 @@ runs:
4761
# GITHUB_ACTION_PATH is this action's directory; three levels up is the
4862
# repo root, which is installable without git metadata because the
4963
# project uses a static version.
64+
if: steps.check.outputs.installed != 'true'
5065
shell: bash
5166
run: uv tool install "$GITHUB_ACTION_PATH/../../.."

.github/actions/report_deployment/action.yml

Lines changed: 5 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,17 +14,10 @@
1414
# metadata is a friendly no-op, so it's safe to run on any closed PR.
1515
#
1616
# Prerequisites:
17-
# - The `odp-releaser` CLI is on the PATH — run the sibling `install`
18-
# action first. (A composite action cannot reference a sibling local
19-
# action itself: relative `uses:` paths resolve against the workflow's
20-
# workspace, not the action's repo — see actions/runner#1348.)
2117
# - Reporter app credentials for the source org — see the GitHub Apps docs.
2218
#
2319
# Minimal caller example:
2420
#
25-
# - name: Install ODP Releaser
26-
# uses: gulfofmaine/odp-releaser/.github/actions/install@<sha-or-tag>
27-
#
2821
# - name: Report deployment
2922
# uses: gulfofmaine/odp-releaser/.github/actions/report_deployment@<sha-or-tag>
3023
# with:
@@ -94,6 +87,11 @@ inputs:
9487
runs:
9588
using: composite
9689
steps:
90+
- name: Install ODP Releaser
91+
uses: $/.github/actions/install
92+
with:
93+
cache_suffix: odp-releaser-${{ github.action_ref }}
94+
9795
- name: Report deployment
9896
shell: bash
9997
env:
@@ -107,11 +105,6 @@ runs:
107105
REPORTER_APP_ID: ${{ inputs.reporter_app_id }}
108106
REPORTER_APP_PRIVATE_KEY: ${{ inputs.reporter_app_private_key }}
109107
run: |
110-
if ! command -v odp-releaser >/dev/null; then
111-
echo "::error::odp-releaser CLI not found on the PATH; run the" \
112-
"gulfofmaine/odp-releaser/.github/actions/install action first"
113-
exit 1
114-
fi
115108
case "$VERBOSITY" in
116109
0) FLAGS=() ;;
117110
1) FLAGS=(-v) ;;

.github/workflows/bump-images.yml

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
#
33
# This workflow is meant to be called by a deploy repo in response to a
44
# repository_dispatch event sent by `odp-releaser notify`. It runs the
5-
# `bump_images` composite action from this repo (checked out at the same
6-
# commit as this workflow file), which reads the incoming client_payload and
5+
# `bump_images` composite action from this repo (resolved at the same commit
6+
# as this workflow file), which reads the incoming client_payload and
77
# this repo's image manifest, then either commits the bump directly or opens
88
# a pull request with the updated image references.
99
#
@@ -364,26 +364,8 @@ jobs:
364364
permission-pull-requests: write
365365
permission-members: read
366366

367-
- name: Checkout odp-releaser
368-
# This reusable workflow's own repo, at the same commit GitHub
369-
# resolved for this workflow file, so the local composite actions
370-
# below (and the CLI they install) stay in lockstep with the caller's
371-
# pinned workflow ref.
372-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
373-
with:
374-
repository: ${{ job.workflow_repository }}
375-
ref: ${{ job.workflow_sha }}
376-
path: .odp-releaser
377-
persist-credentials: false
378-
379-
- name: Hide the odp-releaser checkout from git
380-
# Keep the nested checkout out of the bump: the bump_images action's
381-
# `git add -A` and peter-evans/create-pull-request (which commits
382-
# untracked files) both skip ignored paths.
383-
run: echo "/.odp-releaser/" >> .git/info/exclude
384-
385367
- name: Install ODP Releaser
386-
uses: ./.odp-releaser/.github/actions/install
368+
uses: $/.github/actions/install
387369
with:
388370
cache_suffix: odp-releaser-${{ job.workflow_sha }}
389371

@@ -426,7 +408,7 @@ jobs:
426408

427409
- name: Bump images
428410
id: bump
429-
uses: ./.odp-releaser/.github/actions/bump_images
411+
uses: $/.github/actions/bump_images
430412
with:
431413
sync: ${{ inputs.sync }}
432414
client_payload:
@@ -463,7 +445,7 @@ jobs:
463445
env.HAS_REPORTER_APP == 'true' && inputs.dry_run != true &&
464446
steps.bump.outputs.changed == 'true'
465447
continue-on-error: true
466-
uses: ./.odp-releaser/.github/actions/report_deployment
448+
uses: $/.github/actions/report_deployment
467449
with:
468450
client_payload:
469451
${{ inputs.client_payload || toJSON(github.event.client_payload) }}
@@ -489,7 +471,7 @@ jobs:
489471
steps.bump.outputs.comment_enabled == 'true' &&
490472
steps.bump.outputs.comment_pr_number != ''
491473
continue-on-error: true
492-
uses: ./.odp-releaser/.github/actions/comment_on_pr
474+
uses: $/.github/actions/comment_on_pr
493475
with:
494476
client_payload:
495477
${{ inputs.client_payload || toJSON(github.event.client_payload) }}

.github/workflows/ci.yml

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,44 @@ jobs:
182182
dry_run: true
183183
verbosity: 2
184184

185+
e2e-action-self-install:
186+
name: E2E composite action installs the CLI itself
187+
# The e2e jobs above install the CLI first, so they only ever hit the no-op
188+
# branch of `install`; here `bump_images` has to install it itself.
189+
needs: [e2e-payload]
190+
runs-on: ubuntu-latest
191+
permissions:
192+
contents: read # dry_run writes nothing and pushes nothing
193+
steps:
194+
- uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
195+
with:
196+
persist-credentials: false
197+
198+
- name: Bump images
199+
id: bump
200+
uses: ./.github/actions/bump_images
201+
with:
202+
config_path: tests/e2e/image_manifest.yaml
203+
client_payload: ${{ needs.e2e-payload.outputs.commit_payload }}
204+
dry_run: "true"
205+
verbosity: "2"
206+
207+
- name: Assert the bump ran
208+
env:
209+
CHANGED: ${{ steps.bump.outputs.changed }}
210+
IMAGE_NAME: ${{ steps.bump.outputs.image_name }}
211+
run: |
212+
set -euo pipefail
213+
if [ "$CHANGED" != "true" ]; then
214+
echo "::error::expected changed=true, got '$CHANGED'"
215+
exit 1
216+
fi
217+
if [ "$IMAGE_NAME" != "ghcr.io/gulfofmaine/odp-releaser-e2e-commit" ]; then
218+
echo "::error::unexpected image_name '$IMAGE_NAME'"
219+
exit 1
220+
fi
221+
command -v odp-releaser
222+
185223
e2e-assert:
186224
name: E2E assert notify and bump outputs
187225
needs: [e2e-payload, e2e-notify, e2e-bump-commit, e2e-bump-pr]
@@ -500,6 +538,7 @@ jobs:
500538
e2e-notify,
501539
e2e-bump-commit,
502540
e2e-bump-pr,
541+
e2e-action-self-install,
503542
e2e-assert,
504543
e2e-sync,
505544
]

.github/workflows/notify.yml

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -129,20 +129,8 @@ jobs:
129129
with:
130130
persist-credentials: false
131131

132-
- name: Checkout odp-releaser
133-
# This reusable workflow's own repo, at the same commit GitHub
134-
# resolved for this workflow file, so the local install action below
135-
# (and the CLI it installs) stays in lockstep with the caller's
136-
# pinned workflow ref.
137-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
138-
with:
139-
repository: ${{ job.workflow_repository }}
140-
ref: ${{ job.workflow_sha }}
141-
path: .odp-releaser
142-
persist-credentials: false
143-
144132
- name: Install ODP Releaser
145-
uses: ./.odp-releaser/.github/actions/install
133+
uses: $/.github/actions/install
146134
with:
147135
cache_suffix: odp-releaser-${{ job.workflow_sha }}
148136

.github/workflows/report-merged.yml

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -66,26 +66,13 @@ jobs:
6666
permissions:
6767
contents: read
6868
steps:
69-
- name: Checkout odp-releaser
70-
# This reusable workflow's own repo, at the same commit GitHub
71-
# resolved for this workflow file, so the local composite actions
72-
# below (and the CLI they install) stay in lockstep with the caller's
73-
# pinned workflow ref. The deploy repo itself is never checked out —
74-
# everything needed travels in the PR body.
75-
uses: actions/checkout@3d3c42e5aac5ba805825da76410c181273ba90b1 # v7.0.1
76-
with:
77-
repository: ${{ job.workflow_repository }}
78-
ref: ${{ job.workflow_sha }}
79-
path: .odp-releaser
80-
persist-credentials: false
81-
8269
- name: Install ODP Releaser
83-
uses: ./.odp-releaser/.github/actions/install
70+
uses: $/.github/actions/install
8471
with:
8572
cache_suffix: odp-releaser-${{ job.workflow_sha }}
8673

8774
- name: Report merged deployment
88-
uses: ./.odp-releaser/.github/actions/report_deployment
75+
uses: $/.github/actions/report_deployment
8976
with:
9077
pr_body: ${{ github.event.pull_request.body }}
9178
update_mode: commit
@@ -109,7 +96,7 @@ jobs:
10996
# without odp-releaser metadata, or one from a release that predates
11097
# comment support, is a no-op.
11198
continue-on-error: true
112-
uses: ./.odp-releaser/.github/actions/comment_on_pr
99+
uses: $/.github/actions/comment_on_pr
113100
with:
114101
pr_body: ${{ github.event.pull_request.body }}
115102
update_mode: commit

0 commit comments

Comments
 (0)