Skip to content

Commit 116041e

Browse files
committed
ci(ct): move branch discovery to separate job
We need to reuse the discovered branches in the jobs for the other images, not just the base image. Moving it to a step running first makes the results reusable.
1 parent b32fcf5 commit 116041e

1 file changed

Lines changed: 25 additions & 11 deletions

File tree

.github/workflows/container_maintenance.yml

Lines changed: 25 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,25 @@ env:
2020
NUM_PAST_RELEASES: 3
2121

2222
jobs:
23+
discover:
24+
name: Discover supported releases
25+
runs-on: ubuntu-latest
26+
permissions:
27+
contents: read
28+
packages: read
29+
outputs:
30+
branches: ${{ step.discover.outputs.branches }}
31+
develop-branch: ${{ step.discover.outputs.develop-branch }}
32+
steps:
33+
- name: Discover maintained releases
34+
id: discover
35+
run: |
36+
DEVELOPMENT_BRANCH=$( curl -f -sS https://api.github.com/repos/${{ github.repository }} | jq -r '.default_branch' )
37+
echo "develop-branch=$DEVELOPMENT_BRANCH" | tee -a "${GITHUB_OUTPUT}"
38+
39+
SUPPORTED_BRANCHES=$( curl -f -sS https://api.github.com/repos/IQSS/dataverse/releases | jq -r " .[0:${{ env.NUM_PAST_RELEASES }}] | .[].tag_name, \"${DEVELOPMENT_BRANCH}\" " | tr "\n" " " )
40+
echo "branches=$SUPPORTED_BRANCHES" | tee -a "${GITHUB_OUTPUT}"
41+
2342
base-image:
2443
name: Base Image Matrix Build
2544
runs-on: ubuntu-latest
@@ -28,6 +47,8 @@ jobs:
2847
packages: read
2948
# Only run in upstream repo - avoid unnecessary runs in forks
3049
if: ${{ github.repository_owner == 'IQSS' }}
50+
needs:
51+
- discover
3152
outputs:
3253
# This is a JSON map with keys of branch names (supported releases & develop) and values containing an array of known image tags for the branch
3354
# Example: {"v6.6": ["latest", "6.6-noble", "6.6-noble-r1"], "v6.5": ["6.5-noble", "6.5-noble-r5"], "v6.4": ["6.4-noble", "6.4-noble-r12"], "develop": ["unstable", "6.7-noble", "6.7-noble-p6.2025.3-j17"]}
@@ -55,20 +76,13 @@ jobs:
5576
with:
5677
platforms: ${{ env.PLATFORMS }}
5778

58-
# Discover the releases we want to maintain
59-
- name: Discover maintained releases
60-
id: discover
61-
run: |
62-
echo "FORCE_BUILD=$( [[ "${{ inputs.force_build }}" = "true" ]] && echo 1 || echo 0 )" | tee -a "$GITHUB_ENV"
63-
DEVELOPMENT_BRANCH=$( curl -f -sS https://api.github.com/repos/${{ github.repository }} | jq -r '.default_branch' )
64-
echo "DEVELOPMENT_BRANCH=$DEVELOPMENT_BRANCH" | tee -a "$GITHUB_ENV"
65-
echo "branches=$( curl -f -sS https://api.github.com/repos/IQSS/dataverse/releases | jq -r " .[0:${{ env.NUM_PAST_RELEASES }}] | .[].tag_name, \"${DEVELOPMENT_BRANCH}\" " | tr "\n" " " )" | tee -a "${GITHUB_OUTPUT}"
66-
6779
# Execute matrix build for the discovered branches
6880
- name: Execute build matrix script
6981
id: execute
70-
run: |
71-
.github/workflows/scripts/containers/maintain-base.sh ${{ steps.discover.outputs.branches }}
82+
run: >
83+
FORCE_BUILD=$( [[ "${{ inputs.force_build }}" = "true" ]] && echo 1 || echo 0 )
84+
DEVELOPMENT_BRANCH=${{ needs.discover.outputs.develop-branch }}
85+
.github/workflows/scripts/containers/maintain-base.sh ${{ needs.discover.outputs.branches }}
7286
7387
# TODO: Use the needs.build.outputs.rebuilt_base_images with fromJSON() to create a matrix job.
7488
# Must be a single rank matrix (vector), the branch and base image tag information ships as "branch=tag" string

0 commit comments

Comments
 (0)