-
Notifications
You must be signed in to change notification settings - Fork 0
104 lines (92 loc) · 4.46 KB
/
ci.yml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
name: Docker images CI
run-name: |-
Images CI for "${{ inputs.base_image_tags || github.event.client_payload.base_image_tags }}"${{ github.event.client_payload.git_ref && format(' from upstream #{0} at "{1}"', github.event.client_payload.run_number, github.event.client_payload.git_ref) || '' }}
concurrency:
group: tags:${{ inputs.base_image_tags || github.event.client_payload.base_image_tags }}
cancel-in-progress: false
on:
workflow_dispatch:
inputs:
base_image_tags:
description: |
List of image tags of the mcdreforged/mcdreforged image for the workflow to build as the base images, separated with ",".
For example: "1.2.3,1.2.3-slim,1.2.3-py3.11,1.2.3-py3.11-slim", or just "dev"
type: string
required: true
repository_dispatch:
types:
- trigger-workflow
jobs:
config:
name: Build config
runs-on: ubuntu-latest
steps:
- id: config
uses: actions/github-script@v7
with:
script: |
let inputTags = process.env.BASE_IMAGE_TAGS_WD || process.env.BASE_IMAGE_TAGS_RD
console.log(`Input raw tags: ${inputTags}`)
let baseImageTags = inputTags.split(',').filter(tag => tag !== '')
if (baseImageTags.length === 0) {
core.setFailed("no valid base image tag")
return
}
// use digest whenever possible. fallback to tag name if digest not found
let baseDigest = process.env.BASE_IMAGE_DIGEST
let baseImage = baseDigest ? `mcdreforged/mcdreforged@${baseDigest}` : `mcdreforged/mcdreforged:${baseImageTags[0]}`
core.setOutput('base_image', baseImage)
let tagsMultiline = baseImageTags.join('\n')
core.setOutput('base_target_tags', tagsMultiline)
core.summary.
addRaw('### Input Tags\n', true).addRaw('```', true).addRaw(inputTags, true).addRaw('```\n', true).
addRaw('### Base Image\n', true).addRaw('```', true).addRaw(baseImage, true).addRaw('```\n', true).
addRaw('### Base Target Tags\n', true).addRaw('```', true).addRaw(tagsMultiline, true).addRaw('```\n', true).
write()
env:
BASE_IMAGE_TAGS_WD: ${{ inputs.base_image_tags }}
BASE_IMAGE_TAGS_RD: ${{ github.event.client_payload.base_image_tags }}
BASE_IMAGE_DIGEST: ${{ github.event.client_payload.digest }}
outputs:
base_image: ${{ steps.config.outputs.base_image }}
base_target_tags: ${{ steps.config.outputs.base_target_tags }}
extra:
name: Extra packages
needs: config
uses: ./.github/workflows/image_one.yml
secrets: inherit
with:
dockerfile_name: Dockerfile-extra
build_args: |-
BASE_IMAGE=${{ needs.config.outputs.base_image }}
base_target_tags: ${{ needs.config.outputs.base_target_tags }}
image_name: mcdreforged/mcdreforged-extra
image_tag_maker_script: |-
core.setOutput('target_tags', process.env.BASE_TARGET_TAGS)
openjdk:
name: OpenJDK (jdk${{ matrix.java }}, ${{ matrix.distribution }}${{ matrix.extra == 'true' && ', extra' || '' }})
needs: [config, extra]
strategy:
fail-fast: false
matrix:
java: ['8', '11', '17', '21']
distribution: ['temurin', 'corretto', 'zulu']
extra: ['false', 'true']
uses: ./.github/workflows/image_one.yml
secrets: inherit
with:
dockerfile_name: Dockerfile-openjdk-${{ matrix.distribution }}
build_args: |-
BASE_IMAGE=${{ matrix.extra == 'true' && format('mcdreforged/mcdreforged-extra@{0}', needs.extra.outputs.digest) || needs.config.outputs.base_image }}
JAVA=${{ matrix.java }}
base_target_tags: ${{ needs.config.outputs.base_target_tags }}
image_name: mcdreforged/mcdreforged-${{ matrix.distribution }}
image_tag_maker_script: |-
let targetTags = []
process.env.BASE_TARGET_TAGS.split('\n').forEach(tag => {
targetTags.push(`type=raw,value=${tag},enable=${{ matrix.extra == 'false' && matrix.java == '21' }}`)
targetTags.push(`type=raw,value=${tag}-extra,enable=${{ matrix.extra == 'true' && matrix.java == '21' }}`)
targetTags.push(`type=raw,value=${tag}-jdk${{ matrix.java }},enable=${{ matrix.extra == 'false' }}`)
targetTags.push(`type=raw,value=${tag}-jdk${{ matrix.java }}-extra,enable=${{ matrix.extra == 'true' }}`)
})
core.setOutput('target_tags', targetTags.join('\n'))