12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- name: CI
- on:
- workflow_dispatch:
- push:
- branches: [ "main" ]
- pull_request:
- branches: [ "*" ]
- jobs:
- docker:
- runs-on: ubuntu-latest
- strategy:
- matrix:
- alpine: [ "3.15.10", "3.16.7", "3.17.5", "3.18.3" ]
- variant: [ "", "openrc" ]
- latest: [ false ]
- include:
- - alpine: "3.18.3"
- variant: ""
- latest: true
- - alpine: "3.18.3"
- variant: "openrc"
- latest: true
- steps:
- - name: Checkout
- uses: actions/checkout@v4
- - uses: actions/github-script@v6
- id: alpine-minor-version
- with:
- # The script returns 1.15 from 1.15.10
- script: return "${{ matrix.alpine }}".substr(0, "${{ matrix.alpine }}".lastIndexOf("."))
- result-encoding: string
- - name: Docker metadata
- id: meta
- uses: docker/metadata-action@v5
- with:
- labels: |
- maintainer=The Dockage Authors
- images: |
- dockage/alpine
- flavor: |
- latest=false
- suffix=${{ format(matrix.variant != '' && '-{0}' || '', matrix.variant) }}
- tags: |
- ### versioning strategy
- # dockage/alpine:3.16.2
- # dockage/alpine:3.16
- # dockage/alpine:3
- # dockage/alpine:3.16.2-openrc
- # dockage/alpine:3.16-openrc
- # dockage/alpine:3-openrc
- # dockage/alpine:latest
- type=semver,pattern={{version}},value=${{ matrix.alpine }}
- type=semver,pattern={{major}}.{{minor}},value=${{ matrix.alpine }}
- type=semver,pattern={{major}},value=${{ matrix.alpine }},enable=${{ matrix.latest }}
- type=raw,value=latest,suffix=,enable=${{ matrix.latest && matrix.variant == '' }}
- - name: Set up Docker Buildx
- uses: docker/setup-buildx-action@v2
- - name: Login to DockerHub
- if: ${{ github.event_name != 'pull_request' }}
- uses: docker/login-action@v3
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
- - name: Build images
- uses: docker/bake-action@v3
- with:
- push: ${{ github.ref_name == github.event.repository.default_branch }}
- targets: ${{ matrix.variant }}
- files: |
- ./docker-bake.hcl
- ${{ steps.meta.outputs.bake-file }}
- env:
- CONTEXT: ${{steps.alpine-minor-version.outputs.result}}
- - name: Docker Hub Description
- uses: peter-evans/dockerhub-description@v3
- if: ${{ github.event_name == 'push' && github.ref_name == github.event.repository.default_branch }}
- with:
- username: ${{ secrets.DOCKERHUB_USERNAME }}
- password: ${{ secrets.DOCKERHUB_TOKEN }}
- short-description: ${{ github.event.repository.description }}
|