Skip to content

Commit 2158005

Browse files
committed
create local reusable actions
1 parent 906298c commit 2158005

3 files changed

Lines changed: 82 additions & 21 deletions

File tree

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
name: 'Resolve Firefly Version'
2+
description: 'Extracts the firefly.tag.name from app.config.'
3+
4+
inputs:
5+
config_path:
6+
description: 'Path to the app.config file'
7+
required: true
8+
9+
outputs:
10+
ref:
11+
description: 'The extracted firefly tag'
12+
value: ${{ steps.extract.outputs.ref }}
13+
14+
runs:
15+
using: 'composite'
16+
steps:
17+
- id: extract
18+
shell: bash
19+
run: |
20+
set -euo pipefail
21+
22+
if [[ ! -f "${{ inputs.config_path }}" ]]; then
23+
echo "::error::Configuration file not found at: ${{ inputs.config_path }}"
24+
exit 1
25+
fi
26+
27+
ref="$(
28+
grep -E '^[[:space:]]*firefly\.tag\.name[[:space:]]*=' "${{ inputs.config_path }}" | cut -d'"' -f2
29+
)"
30+
31+
if [[ -z "$ref" ]]; then
32+
echo "ERROR: firefly.tag.name not found or malformed in ${{ inputs.config_path }}"
33+
exit 1
34+
fi
35+
36+
echo "Using firefly tag: $ref"
37+
echo "ref=$ref" >> "$GITHUB_OUTPUT"
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
name: 'Resolve tags'
2+
description: 'Determines the git ref and image tag based on inputs and event type'
3+
4+
inputs:
5+
git_tag:
6+
description: 'Manual git tag input'
7+
required: false
8+
img_tag:
9+
description: 'Manual image tag input'
10+
required: false
11+
12+
outputs:
13+
ref:
14+
description: "The resolved git reference"
15+
value: ${{ github.event_name == 'release' && github.event.release.tag_name || inputs.git_tag }}
16+
tag:
17+
description: "The resolved image tag"
18+
value: ${{ steps.logic.outputs.tag }}
19+
20+
runs:
21+
using: "composite"
22+
steps:
23+
- id: logic
24+
shell: bash
25+
run: |
26+
set -euo pipefail
27+
if [[ "${{ github.event_name }}" == "release" ]]; then
28+
echo "tag=${{ github.event.release.name }}" >> $GITHUB_OUTPUT
29+
else
30+
FINAL_TAG="${{ inputs.img_tag }}"
31+
if [[ -z "$FINAL_TAG" ]]; then
32+
FINAL_TAG="${{ inputs.git_tag }}"
33+
fi
34+
echo "tag=$FINAL_TAG" >> $GITHUB_OUTPUT
35+
fi

.github/workflows/build_publish.yml

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -28,34 +28,22 @@ jobs:
2828
runs-on: ubuntu-latest
2929

3030
steps:
31-
# ------------------------------------------------------------
32-
# Resolve checkout ref and image tag
33-
# - If triggered by a release event, use the release tag for both ref and image tag
34-
# - Otherwise, prefer `inputs.img_tag` (short form) and fallback to `inputs.git_tag`
35-
# This ensures `git_tag` is required and independent of `img_tag`.
36-
# ------------------------------------------------------------
31+
# -------------------------------------------------------------
32+
# Use local action to resolve git ref and image tag from inputs
33+
# -------------------------------------------------------------
3734
- name: Resolve tags
3835
id: resolve_tags
39-
run: |
40-
if [[ "${{ github.event_name }}" == "release" ]]; then
41-
echo "ref=${{ github.event.release.tag_name }}" >> $GITHUB_OUTPUT
42-
echo "tag=${{ github.event.release.name }}" >> $GITHUB_OUTPUT
43-
else
44-
echo "ref=${{ inputs.git_tag }}" >> $GITHUB_OUTPUT
45-
if [[ -n "${{ inputs.img_tag }}" ]]; then
46-
echo "tag=${{ inputs.img_tag }}" >> $GITHUB_OUTPUT
47-
else
48-
echo "tag=${{ inputs.git_tag }}" >> $GITHUB_OUTPUT
49-
fi
50-
fi
36+
uses: firefly/.github/actions/resolve-tags
37+
with:
38+
git_tag: ${{ inputs.git_tag }}
39+
img_tag: ${{ inputs.img_tag }}
5140

5241
# ------------------------------------------------------------
53-
# Checkout firefly repo at the resolved ref
42+
# Checkout firefly (this repo)
5443
# ------------------------------------------------------------
5544
- name: Checkout Firefly
5645
uses: actions/checkout@v4
5746
with:
58-
repository: Caltech-IPAC/firefly
5947
ref: ${{ steps.resolve_tags.outputs.ref }}
6048
path: firefly
6149

@@ -99,7 +87,8 @@ jobs:
9987
file: firefly/docker/Dockerfile
10088
platforms: linux/amd64,linux/arm64
10189
push: ${{ github.event_name == 'release' || inputs.push_image == 'true' }}
102-
tags: ghcr.io/${{ github.repository }}:${{ steps.resolve_tags.outputs.tag }}
90+
# docker buildx does not allow uppercase letters in tags, so we convert to lowercase here
91+
tags: ghcr.io/caltech-ipac/firefly:${{ steps.resolve_tags.outputs.tag }}
10392
build-args: |
10493
env=ops
10594
cache-from: type=gha

0 commit comments

Comments
 (0)