|
| 1 | +--- |
| 2 | +name: 'Build container' |
| 3 | + |
| 4 | +on: |
| 5 | + workflow_dispatch: |
| 6 | + pull_request: |
| 7 | + branches: |
| 8 | + - master |
| 9 | + paths: |
| 10 | + - container/** |
| 11 | + push: |
| 12 | + branches: |
| 13 | + - master |
| 14 | + paths: |
| 15 | + - container/** |
| 16 | + |
| 17 | +concurrency: |
| 18 | + group: ${{ github.workflow }}-${{ github.ref }} |
| 19 | + cancel-in-progress: true |
| 20 | + |
| 21 | +jobs: |
| 22 | + build: |
| 23 | + runs-on: ubuntu-latest |
| 24 | + |
| 25 | + permissions: |
| 26 | + contents: read |
| 27 | + packages: write |
| 28 | + |
| 29 | + steps: |
| 30 | + - name: Checkout |
| 31 | + uses: classabbyamp/treeless-checkout-action@v1 |
| 32 | + |
| 33 | + - name: Get image release |
| 34 | + id: release |
| 35 | + run: | |
| 36 | + # gets the list of all date-shaped tags for the image, finds the most recent one |
| 37 | + tag="$(skopeo list-tags "docker://ghcr.io/${{ github.repository_owner }}/void-mklive" | \ |
| 38 | + jq -r '.Tags | sort | reverse | map(select(test("^[0-9]{8}(R[0-9]+)?$")))[0]')" |
| 39 | + # tags from a different day or pre-YYYYMMDDRN |
| 40 | + if [ "${tag%R*}" != "$(date -u +%Y%m%d)" ] || [ "${tag%R*}" = "${tag}" ]; then |
| 41 | + rel=1 |
| 42 | + else |
| 43 | + rel=$(( ${tag##*R} + 1 )) |
| 44 | + fi |
| 45 | + echo "rel=${rel}" >> "${GITHUB_OUTPUT}" |
| 46 | +
|
| 47 | + - name: Docker metadata |
| 48 | + id: meta |
| 49 | + uses: docker/metadata-action@v4 |
| 50 | + with: |
| 51 | + images: | |
| 52 | + ghcr.io/${{ github.repository_owner }}/void-mklive |
| 53 | + tags: | |
| 54 | + type=sha,prefix= |
| 55 | + type=raw,value=latest,enable={{is_default_branch}} |
| 56 | + type=raw,value={{date 'YYYYMMDD'}}R${{ steps.release.outputs.rel }},enable={{is_default_branch}},priority=1000 |
| 57 | + flavor: latest=false |
| 58 | + labels: | |
| 59 | + org.opencontainers.image.authors=Void Linux team and contributors |
| 60 | + org.opencontainers.image.url=https://voidlinux.org |
| 61 | + org.opencontainers.image.documentation=https://github.com/${{ github.repository }} |
| 62 | + org.opencontainers.image.source=https://github.com/${{ github.repository }} |
| 63 | + org.opencontainers.image.vendor=Void Linux |
| 64 | + org.opencontainers.image.title=Void Linux mklive container |
| 65 | + org.opencontainers.image.description=Image for building mklive images |
| 66 | +
|
| 67 | + - name: Set up Docker Buildx |
| 68 | + uses: docker/setup-buildx-action@v2 |
| 69 | + |
| 70 | + - name: Login to GCHR |
| 71 | + if: github.event_name != 'pull_request' |
| 72 | + uses: docker/login-action@v2 |
| 73 | + with: |
| 74 | + registry: ghcr.io |
| 75 | + username: ${{ github.actor }} |
| 76 | + password: ${{ secrets.GITHUB_TOKEN }} |
| 77 | + |
| 78 | + - name: Build and push images |
| 79 | + id: build_and_push |
| 80 | + uses: docker/bake-action@v3 |
| 81 | + with: |
| 82 | + push: ${{ github.event_name != 'pull_request' }} |
| 83 | + targets: void-mklive |
| 84 | + files: | |
| 85 | + container/docker-bake.hcl |
| 86 | + ${{ steps.meta.outputs.bake-file }} |
| 87 | + set: | |
| 88 | + _common.cache-to=type=gha |
| 89 | + _common.cache-from=type=gha |
0 commit comments