From 69a011755af0ecf274ced95136e590164f35baa1 Mon Sep 17 00:00:00 2001 From: Fallen_Breath Date: Fri, 29 Dec 2023 02:41:57 +0800 Subject: [PATCH] w --- .github/workflows/ci.yml | 45 +++++++++++++++++++-------------- .github/workflows/image_one.yml | 4 --- 2 files changed, 26 insertions(+), 23 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index c4c2713..7384086 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -1,5 +1,5 @@ name: Docker images -run-name: Images CI for "${{ inputs.base_image_tags || github.event.client_payload.base_image_tags }}"${{ github.event.client_payload.git_ref && ' at ' + github.event.client_payload.git_ref || '' }} +run-name: Images CI for "${{ inputs.base_image_tags || github.event.client_payload.base_image_tags }}"${{ github.event.client_payload.git_ref && format(' at {0}', github.event.client_payload.git_ref) || '' }} on: workflow_dispatch: @@ -16,53 +16,60 @@ on: jobs: config: - name: Build matrix from input + name: Build config runs-on: ubuntu-latest steps: - - name: Build matrix - id: config + - id: config uses: actions/github-script@v7 with: script: | let input_tags = process.env.BASE_IMAGE_TAGS_WD || process.env.BASE_IMAGE_TAGS_RD console.log(`Input raw tags: ${input_tags}`) - let tags = input_tags.split(',').filter(tag => tag !== '') - if (tags.length == 0) { + let base_image_tags = input_tags.split(',').filter(tag => tag !== '') + if (base_image_tags.length == 0) { core.setFailed("no valid base image tag") return } - let tagsMultiline = tags.join('\n') - core.setOutput('tag', tags[0]) - core.setOutput('tags', tagsMultiline) + let tagsMultiline = base_image_tags.join('\n') + core.setOutput('base_image_tag', base_image_tags[0]) + core.setOutput('base_image_tags', tagsMultiline) core.summary.addHeading('Input tags').addCodeBlock(tagsMultiline).write() + console.log('base_image_tags:') + base_image_tags.forEach(tag => console.log(`- ${tag}`)) + function expr(s) { + let ret = '$' + '{{ ' + s; + return ret + ' }}' + } openjdk_tags = [] - tags.forEach(tag => { - openjdk_tags.push(`type=raw,value=${tag}` + ",enable=${{ matrix.extra == 'false' && matrix.java == '17' }}") - openjdk_tags.push(`type=raw,value=${tag}` + "-extra,enable=${{ matrix.extra == 'true' && matrix.java == '17' }}") - openjdk_tags.push(`type=raw,value=${tag}` + "-jdk${{ matrix.java }},enable=${{ matrix.extra == 'false' }}") - openjdk_tags.push(`type=raw,value=${tag}` + "-jdk${{ matrix.java }}-extra,enable=${{ matrix.extra == 'true' }}") + base_image_tags.forEach(tag => { + openjdk_tags.push(`type=raw,value=${tag},enable=${expr("matrix.extra == 'false' && matrix.java == '17'")}`) + openjdk_tags.push(`type=raw,value=${tag}-extra,enable=${expr("matrix.extra == 'true' && matrix.java == '17'")}`) + openjdk_tags.push(`type=raw,value=${tag}-jdk${expr("matrix.java")},enable=${expr("matrix.extra == 'false'")}`) + openjdk_tags.push(`type=raw,value=${tag}-jdk${expr("matrix.java")}-extra,enable=${expr("matrix.extra == 'true'")}`) }) core.setOutput('openjdk_tags', openjdk_tags.join('\n')) + console.log('openjdk_tags:') + openjdk_tags.forEach(tag => console.log(`- ${tag}`)) env: BASE_IMAGE_TAGS_WD: ${{ inputs.base_image_tags }} BASE_IMAGE_TAGS_RD: ${{ github.event.client_payload.base_image_tags }} outputs: - base_image_tag: ${{ steps.config.outputs.tag }} - base_image_tags: ${{ steps.config.outputs.tags }} + base_image_tag: ${{ steps.config.outputs.base_image_tag }} + base_image_tags: ${{ steps.config.outputs.base_image_tags }} openjdk_tags: ${{ steps.config.outputs.openjdk_tags }} extra: + name: Extra packages needs: config uses: ./.github/workflows/image_one.yml secrets: inherit with: - job_name: Extra packages dockerfile_name: Dockerfile-extra build_args: |- BASE_IMAGE=mcdreforged/mcdreforged:${{ needs.config.outputs.base_image_tag }} @@ -70,7 +77,8 @@ jobs: image_tags: ${{ needs.config.outputs.base_image_tags }} openjdk: - needs: extra + name: OpenJDK (jdk${{ matrix.java }}, ${{ matrix.distribution }}${{ matrix.extra == 'true' && ', extra' || '' }}) + needs: [config, extra] strategy: matrix: java: ['8', '11', '17', '21'] @@ -80,7 +88,6 @@ jobs: uses: ./.github/workflows/image_one.yml secrets: inherit with: - job_name: OpenJDK (jdk${{ matrix.java }}, ${{ matrix.distribution }}${{ matrix.extra == 'true' && ', extra' || '' }}) dockerfile_name: Dockerfile-${{ matrix.distribution }} build_args: |- BASE_IMAGE=mcdreforged/${{ matrix.extra == 'true' && 'mcdreforged-extra' || 'mcdreforged' }}:${{ needs.config.outputs.base_image_tag }} diff --git a/.github/workflows/image_one.yml b/.github/workflows/image_one.yml index 0869720..cbab523 100644 --- a/.github/workflows/image_one.yml +++ b/.github/workflows/image_one.yml @@ -3,9 +3,6 @@ name: step.image_one on: workflow_call: inputs: - job_name: - type: string - required: false dockerfile_name: type: string required: true @@ -28,7 +25,6 @@ on: jobs: image: - name: ${{ inputs.job_name }} runs-on: ubuntu-latest outputs: imageid: ${{ steps.build.outputs.imageid }}