Skip to content

Commit

Permalink
Build images automatically via GitHub Actions
Browse files Browse the repository at this point in the history
  • Loading branch information
vhotspur committed Aug 7, 2024
1 parent dc460e7 commit 87faae2
Show file tree
Hide file tree
Showing 3 changed files with 339 additions and 0 deletions.
273 changes: 273 additions & 0 deletions .github/workflows/docker.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,273 @@

name: Docker images

# WARNING: generated file, use update.py for updates

on: [push, pull_request]

jobs:


image-openjdk8:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk8
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk8-with-ant-gcc:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk8-with-ant-gcc
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk9:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk9
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk10:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk10
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk11:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk11
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk11-with-ant-gcc:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk11-with-ant-gcc
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk12:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk12
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk13:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk13
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk14:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk14
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk15:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk15
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk16:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk16
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk17:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk17
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk18:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk18
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk19:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk19
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk20:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk20
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk21:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk21
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk22:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk22
push: ${{ github.ref == 'refs/heads/master' }}



image-openjdk23-ea:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openjdk23-ea
push: ${{ github.ref == 'refs/heads/master' }}



image-openj9-openjdk8:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openj9-openjdk8
push: ${{ github.ref == 'refs/heads/master' }}



image-openj9-openjdk11:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openj9-openjdk11
push: ${{ github.ref == 'refs/heads/master' }}



image-openj9-openjdk17:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openj9-openjdk17
push: ${{ github.ref == 'refs/heads/master' }}



image-openj9-openjdk21:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: openj9-openjdk21
push: ${{ github.ref == 'refs/heads/master' }}


39 changes: 39 additions & 0 deletions .github/workflows/lib-build-image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@

name: _ Image building helpers

on:
workflow_call:
inputs:
name:
required: true
type: string
push:
required: false
type: boolean
default: false

jobs:
build:
runs-on: ubuntu-latest

steps:
- name: Checkout repository
uses: actions/checkout@v4

- name: Load configuration and versions
run: cat version.rc >> "$GITHUB_ENV"

- name: Log into image registry
uses: docker/login-action@v3
with:
registry: ${{ env.DOCKER_REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Build and push the Docker image
id: build-and-push
uses: docker/build-push-action@v5
with:
context: "{{defaultContext}}:buildenv-${{ inputs.name }}"
push: ${{ inputs.push }}
tags: "${{ env.DOCKER_REGISTRY }}/${{ env.DOCKER_REGISTRY_NAMESPACE }}/${{ env.DOCKER_IMAGE_NAME }}:${{ env.DOCKER_IMAGE_VERSION_TAG }}-${{ inputs.name }}"
27 changes: 27 additions & 0 deletions update.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,6 +218,29 @@
CMD ["/bin/bash"]
'''

GITHUB_WORKFLOW_FILENAME = '.github/workflows/docker.yml'
GITHUB_WORKFLOW_HEADER = '''
name: Docker images
# WARNING: generated file, use update.py for updates
on: [push, pull_request]
jobs:
'''
GITHUB_WORKFLOW_TEMPLATE = '''
image-{name}:
permissions:
contents: read
packages: write
id-token: write
uses: ./.github/workflows/lib-build-image.yml
with:
name: {name}
push: ${{{{ github.ref == 'refs/heads/master' }}}}
'''


def replace_shell_pseudo_variables(where, variables):
if not variables:
Expand Down Expand Up @@ -284,6 +307,10 @@ def main():
print("Updating {name} ...".format(**version_config), file=sys.stderr)
update_version(f, version_config, docker_config)

with open(GITHUB_WORKFLOW_FILENAME, 'w') as f:
print(GITHUB_WORKFLOW_HEADER, file=f)
for version_config in VERSIONS:
print(GITHUB_WORKFLOW_TEMPLATE.format(**version_config), file=f)

if __name__ == '__main__':
main()

0 comments on commit 87faae2

Please sign in to comment.