forked from Job79/devcontainer
161 lines
6.4 KiB
YAML
161 lines
6.4 KiB
YAML
name: Build containers
|
|
on:
|
|
workflow_dispatch:
|
|
push:
|
|
branches: ["main"]
|
|
paths: ["containers/**", ".gitea/workflows/build.yaml"]
|
|
pull_request:
|
|
branches: ["main"]
|
|
paths: ["containers/**", ".gitea/workflows/build.yaml"]
|
|
|
|
jobs:
|
|
changes:
|
|
runs-on: job-v2
|
|
outputs:
|
|
any_change: ${{ steps.filter.outputs.workflow == 'true' || github.event_name == 'schedule' || github.event_name == 'workflow_dispatch'}}
|
|
fedora: ${{ steps.filter.outputs.fedora == 'true' }}
|
|
php: ${{ steps.filter.outputs.php == 'true' }}
|
|
rust: ${{ steps.filter.outputs.rust == 'true' }}
|
|
dotnet: ${{ steps.filter.outputs.dotnet == 'true' }}
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- uses: https://github.com/dorny/paths-filter@v3
|
|
id: filter
|
|
with:
|
|
filters: |
|
|
workflow: ['.gitea/workflows/build.yaml']
|
|
fedora: ['containers/fedora/**']
|
|
php: ['containers/php/**']
|
|
rust: ['containers/rust/**']
|
|
dotnet: ['containers/dotnet/**']
|
|
|
|
base-image:
|
|
needs: [changes]
|
|
if: ${{ needs.changes.outputs.fedora == 'true' || needs.changes.outputs.any_change == 'true' }}
|
|
runs-on: job-v2
|
|
steps:
|
|
- uses: actions/checkout@v4
|
|
- name: Log in
|
|
uses: redhat-actions/podman-login@v1
|
|
with:
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- name: Build
|
|
id: build
|
|
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
|
|
with:
|
|
image: maurice/fedora
|
|
tags: ${{ github.ref_name }}
|
|
context: ./containers/fedora
|
|
containerfiles: ./containers/fedora/Containerfile
|
|
- name: Push
|
|
uses: redhat-actions/push-to-registry@v2
|
|
with:
|
|
image: ${{ steps.build.outputs.image }}
|
|
tags: ${{ steps.build.outputs.tags }}
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
extra-args: |
|
|
--compression-format=zstd
|
|
--compression-level=12
|
|
|
|
dependent-images:
|
|
needs: [changes, base-image]
|
|
if: always() && needs.changes.result == 'success' && (needs.base-image.result == 'success' || needs.base-image.result == 'skipped')
|
|
runs-on: job-v2
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
container: [php, rust, dotnet]
|
|
steps:
|
|
- name: Check if build needed
|
|
id: check
|
|
run: |
|
|
if [[ "${{ matrix.container }}" == "php" && "${{ needs.changes.outputs.php }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ matrix.container }}" == "rust" && "${{ needs.changes.outputs.rust }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ matrix.container }}" == "dotnet" && "${{ needs.changes.outputs.dotnet }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ needs.changes.outputs.any_change }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
- name: Clone repo
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: actions/checkout@v4
|
|
- name: Log in
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: redhat-actions/podman-login@v1
|
|
with:
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- name: Build
|
|
id: build
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
|
|
with:
|
|
image: maurice/${{ matrix.container }}
|
|
tags: ${{ github.ref_name }}
|
|
context: ./containers/${{ matrix.container }}
|
|
containerfiles: ./containers/${{ matrix.container }}/Containerfile
|
|
build-args: TAG=${{ github.ref_name }}
|
|
- name: Push
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: redhat-actions/push-to-registry@v2
|
|
with:
|
|
image: ${{ steps.build.outputs.image }}
|
|
tags: ${{ steps.build.outputs.tags }}
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
extra-args: |
|
|
--compression-format=zstd
|
|
--compression-level=12
|
|
|
|
manual-images:
|
|
needs: [changes, base-image]
|
|
if: always() && needs.changes.result == 'success' && (needs.base-image.result == 'success' || needs.base-image.result == 'skipped')
|
|
runs-on: job-v2
|
|
strategy:
|
|
fail-fast: false
|
|
matrix:
|
|
container: [php, rust, dotnet]
|
|
steps:
|
|
- name: Check if build needed
|
|
id: check
|
|
run: |
|
|
if [[ "${{ matrix.container }}" == "php" && "${{ needs.changes.outputs.php }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ matrix.container }}" == "rust" && "${{ needs.changes.outputs.rust }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ matrix.container }}" == "dotnet" && "${{ needs.changes.outputs.dotnet }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
if [[ "${{ needs.changes.outputs.any_change }}" == "true" ]]; then echo "run=true" >> $GITHUB_OUTPUT; fi
|
|
- name: Clone repo
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: actions/checkout@v4
|
|
- name: Log in
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: redhat-actions/podman-login@v1
|
|
with:
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
- name: Build
|
|
id: build
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: job79/buildah-build@65b3793a1370c1ccd74a5c0d090d70eb9637a4ef
|
|
with:
|
|
image: maurice/${{ matrix.container }}
|
|
tags: ${{ github.ref_name }}
|
|
context: ./containers/${{ matrix.container }}
|
|
containerfiles: ./containers/${{ matrix.container }}/Containerfile
|
|
build-args: TAG=${{ github.ref_name }}
|
|
- name: Push
|
|
if: steps.check.outputs.run == 'true'
|
|
uses: redhat-actions/push-to-registry@v2
|
|
with:
|
|
image: ${{ steps.build.outputs.image }}
|
|
tags: ${{ steps.build.outputs.tags }}
|
|
registry: git.plabble.org
|
|
username: ${{ secrets.REGISTRY_USERNAME }}
|
|
password: ${{ secrets.REGISTRY_TOKEN }}
|
|
extra-args: |
|
|
--compression-format=zstd
|
|
--compression-level=12
|