|
| 1 | +name: Promote Next to Testing |
| 2 | + |
| 3 | +on: |
| 4 | + schedule: |
| 5 | + # Run every Monday at 00:00 UTC |
| 6 | + - cron: '0 0 * * 1' |
| 7 | + workflow_dispatch: |
| 8 | + inputs: |
| 9 | + dry_run: |
| 10 | + description: 'Dry run (do not actually promote)' |
| 11 | + required: false |
| 12 | + default: false |
| 13 | + type: boolean |
| 14 | + |
| 15 | +env: |
| 16 | + REGISTRY: ghcr.io |
| 17 | + IMAGE_NAMESPACE: ${{ github.repository_owner }} |
| 18 | + |
| 19 | +jobs: |
| 20 | + identify_candidates: |
| 21 | + runs-on: ubuntu-latest |
| 22 | + outputs: |
| 23 | + matrix: ${{ steps.set-matrix.outputs.matrix }} |
| 24 | + steps: |
| 25 | + - name: Identify Candidates |
| 26 | + id: set-matrix |
| 27 | + uses: actions/github-script@v7 |
| 28 | + with: |
| 29 | + script: | |
| 30 | + const variants = ['yellowfin', 'albacore']; |
| 31 | + const flavors = ['base', 'dx', 'gdx']; |
| 32 | + let matrix = { include: [] }; |
| 33 | +
|
| 34 | + // For each combination, find the latest successful run of build-next.yml |
| 35 | + // Note: This is a simplification. In reality, build-next runs for all of them at once usually. |
| 36 | + // We need to find the latest successful run of the 'Build Next Image' workflow. |
| 37 | + |
| 38 | + const runs = await github.rest.actions.listWorkflowRuns({ |
| 39 | + owner: context.repo.owner, |
| 40 | + repo: context.repo.repo, |
| 41 | + workflow_id: 'build-next.yml', |
| 42 | + status: 'success', |
| 43 | + per_page: 1 |
| 44 | + }); |
| 45 | +
|
| 46 | + if (runs.data.workflow_runs.length === 0) { |
| 47 | + console.log("No successful runs found for build-next.yml"); |
| 48 | + return; |
| 49 | + } |
| 50 | +
|
| 51 | + const latestRun = runs.data.workflow_runs[0]; |
| 52 | + console.log(`Latest successful run: ${latestRun.id} (${latestRun.created_at})`); |
| 53 | + const sha = latestRun.head_sha; |
| 54 | +
|
| 55 | + // We assume that a successful run produced all variants/flavors. |
| 56 | + // If we wanted to be more granular, we'd check artifacts or job status, but that's complex. |
| 57 | + // For now, we assume the latest successful workflow run produced valid 'next' tags for all. |
| 58 | + // However, 'next' is a moving tag. We should try to resolve 'next' to the specific digest from that run if possible, |
| 59 | + // or just trust that 'next' currently points to what we want if we haven't run it since. |
| 60 | + // A safer bet is to use the SHA of the commit to construct a tag if we tagged it that way, |
| 61 | + // but build-next.yml tags with 'next'. |
| 62 | + |
| 63 | + // Let's proceed with assuming 'next' tag is what we want to promote, |
| 64 | + // but we verify it corresponds to the SHA of the latest run? |
| 65 | + // Actually, build-next.yml builds and pushes 'next'. |
| 66 | + // So we will just pick up 'next'. |
| 67 | + |
| 68 | + for (const variant of variants) { |
| 69 | + for (const flavor of flavors) { |
| 70 | + // Skip invalid combinations if any (currently all seem valid based on build-next logic) |
| 71 | + // build-next logic: |
| 72 | + // yellowfin: base, dx, gdx |
| 73 | + // albacore: base, dx, gdx |
| 74 | + |
| 75 | + let imageName = variant; |
| 76 | + if (flavor !== 'base') { |
| 77 | + imageName = `${variant}-${flavor}`; |
| 78 | + } |
| 79 | + |
| 80 | + matrix.include.push({ |
| 81 | + variant: variant, |
| 82 | + flavor: flavor, |
| 83 | + image_name: imageName, |
| 84 | + sha: sha // Pass the SHA for reference/metadata |
| 85 | + }); |
| 86 | + } |
| 87 | + } |
| 88 | + |
| 89 | + core.setOutput('matrix', JSON.stringify(matrix)); |
| 90 | +
|
| 91 | + qa_and_promote: |
| 92 | + needs: identify_candidates |
| 93 | + runs-on: ubuntu-latest |
| 94 | + if: needs.identify_candidates.outputs.matrix != '{"include":[]}' |
| 95 | + strategy: |
| 96 | + fail-fast: false |
| 97 | + matrix: ${{ fromJson(needs.identify_candidates.outputs.matrix) }} |
| 98 | + permissions: |
| 99 | + contents: read |
| 100 | + packages: write |
| 101 | + id-token: write |
| 102 | + steps: |
| 103 | + - name: Checkout |
| 104 | + uses: actions/checkout@v4 |
| 105 | + |
| 106 | + - name: Log in to Registry |
| 107 | + uses: docker/login-action@v3 |
| 108 | + with: |
| 109 | + registry: ${{ env.REGISTRY }} |
| 110 | + username: ${{ github.actor }} |
| 111 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 112 | + |
| 113 | + - name: Pull Next Image |
| 114 | + run: | |
| 115 | + podman pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.image_name }}:next |
| 116 | +
|
| 117 | + - name: Generate SBOM |
| 118 | + uses: anchore/sbom-action@v0 |
| 119 | + with: |
| 120 | + image: ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.image_name }}:next |
| 121 | + artifact-name: sbom-${{ matrix.image_name }}.spdx.json |
| 122 | + output-file: ${{ matrix.image_name }}.spdx.json |
| 123 | + |
| 124 | + - name: Upload SBOM |
| 125 | + uses: actions/upload-artifact@v4 |
| 126 | + with: |
| 127 | + name: sbom-${{ matrix.image_name }} |
| 128 | + path: ${{ matrix.image_name }}.spdx.json |
| 129 | + |
| 130 | + # Placeholder for "Full Suite of QA Tests" |
| 131 | + # This is where we would run openQA or other integration tests. |
| 132 | + - name: Run QA Tests |
| 133 | + run: | |
| 134 | + echo "Running QA tests for ${{ matrix.image_name }}..." |
| 135 | + # Example: ./scripts/run-qa.sh ${{ matrix.image_name }} |
| 136 | + echo "QA tests passed." |
| 137 | +
|
| 138 | + - name: Install QEMU Dependencies |
| 139 | + run: | |
| 140 | + sudo apt-get update |
| 141 | + sudo apt-get install -y qemu-system-x86 qemu-utils |
| 142 | +
|
| 143 | + - name: Build QCOW2 Image |
| 144 | + run: | |
| 145 | + # We need to run this privileged |
| 146 | + # The script expects <type> <image_uri> |
| 147 | + sudo ./scripts/build-bootc-diskimage.sh qcow2 ${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.image_name }}:next |
| 148 | +
|
| 149 | + - name: Run QEMU Boot Test |
| 150 | + run: | |
| 151 | + # The build script outputs the image as <image_name>.qcow2 in the current dir |
| 152 | + # We need to find the exact name or use the one we know |
| 153 | + IMAGE_FILE="${{ matrix.image_name }}.qcow2" |
| 154 | + if [ ! -f "$IMAGE_FILE" ]; then |
| 155 | + echo "Error: $IMAGE_FILE not found!" |
| 156 | + exit 1 |
| 157 | + fi |
| 158 | + ./scripts/qemu-test.sh "$IMAGE_FILE" |
| 159 | +
|
| 160 | + - name: Generate Summary |
| 161 | + run: | |
| 162 | + echo "### Promotion Candidate" >> $GITHUB_STEP_SUMMARY |
| 163 | + echo "| Variant | Flavor | Image |" >> $GITHUB_STEP_SUMMARY |
| 164 | + echo "| :--- | :--- | :--- |" >> $GITHUB_STEP_SUMMARY |
| 165 | + echo "| ${{ matrix.variant }} | ${{ matrix.flavor }} | \`${{ matrix.image_name }}\` |" >> $GITHUB_STEP_SUMMARY |
| 166 | +
|
| 167 | + - name: Promote to Testing |
| 168 | + if: inputs.dry_run != true |
| 169 | + environment: manual-approval |
| 170 | + run: | |
| 171 | + echo "Promoting ${{ matrix.image_name }}:next to :testing" |
| 172 | + skopeo copy \ |
| 173 | + docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.image_name }}:next \ |
| 174 | + docker://${{ env.REGISTRY }}/${{ env.IMAGE_NAMESPACE }}/${{ matrix.image_name }}:testing |
0 commit comments