|
| 1 | +--- |
| 2 | +name: 'build container images' |
| 3 | +on: |
| 4 | + push: |
| 5 | + branches: |
| 6 | + - master |
| 7 | + tags: |
| 8 | + - '*' |
| 9 | +concurrency: |
| 10 | + group: ci-image-${{ github.head_ref || github.ref }}-${{ github.repository }} |
| 11 | + cancel-in-progress: true |
| 12 | +jobs: |
| 13 | + containerImages: |
| 14 | + runs-on: arc-runner-localagent |
| 15 | + steps: |
| 16 | + - name: Checkout |
| 17 | + uses: actions/checkout@v4 |
| 18 | + |
| 19 | + - name: Prepare |
| 20 | + id: prep |
| 21 | + run: | |
| 22 | + DOCKER_IMAGE=quay.io/mudler/localagi |
| 23 | + # Use branch name as default |
| 24 | + VERSION=${GITHUB_REF#refs/heads/} |
| 25 | + BINARY_VERSION=$(git describe --always --tags --dirty) |
| 26 | + SHORTREF=${GITHUB_SHA::8} |
| 27 | + # If this is git tag, use the tag name as a docker tag |
| 28 | + if [[ $GITHUB_REF == refs/tags/* ]]; then |
| 29 | + VERSION=${GITHUB_REF#refs/tags/} |
| 30 | + fi |
| 31 | + TAGS="${DOCKER_IMAGE}:${VERSION},${DOCKER_IMAGE}:${SHORTREF}" |
| 32 | + # If the VERSION looks like a version number, assume that |
| 33 | + # this is the most recent version of the image and also |
| 34 | + # tag it 'latest'. |
| 35 | + if [[ $VERSION =~ ^[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}$ ]]; then |
| 36 | + TAGS="$TAGS,${DOCKER_IMAGE}:latest" |
| 37 | + fi |
| 38 | + # Set output parameters. |
| 39 | + echo ::set-output name=binary_version::${BINARY_VERSION} |
| 40 | + echo ::set-output name=tags::${TAGS} |
| 41 | + echo ::set-output name=docker_image::${DOCKER_IMAGE} |
| 42 | + - name: Set up QEMU |
| 43 | + uses: docker/setup-qemu-action@master |
| 44 | + with: |
| 45 | + platforms: all |
| 46 | + |
| 47 | + - name: Set up Docker Buildx |
| 48 | + id: buildx |
| 49 | + uses: docker/setup-buildx-action@master |
| 50 | + |
| 51 | + - name: Login to DockerHub |
| 52 | + if: github.event_name != 'pull_request' |
| 53 | + uses: docker/login-action@v3 |
| 54 | + with: |
| 55 | + registry: quay.io |
| 56 | + username: ${{ secrets.DOCKER_USERNAME }} |
| 57 | + password: ${{ secrets.DOCKER_PASSWORD }} |
| 58 | + - name: Extract metadata (tags, labels) for Docker |
| 59 | + id: meta |
| 60 | + uses: docker/metadata-action@2a4836ac76fe8f5d0ee3a0d89aa12a80cc552ad3 |
| 61 | + with: |
| 62 | + images: quay.io/mudler/localagi |
| 63 | + tags: | |
| 64 | + type=ref,event=branch,suffix=-{{date 'YYYYMMDDHHmmss'}} |
| 65 | + type=semver,pattern={{raw}} |
| 66 | + type=sha,suffix=-{{date 'YYYYMMDDHHmmss'}} |
| 67 | + type=ref,event=branch |
| 68 | + flavor: | |
| 69 | + latest=auto |
| 70 | + prefix= |
| 71 | + suffix= |
| 72 | +
|
| 73 | + - name: Build |
| 74 | + uses: docker/build-push-action@v6 |
| 75 | + with: |
| 76 | + builder: ${{ steps.buildx.outputs.name }} |
| 77 | + build-args: | |
| 78 | + VERSION=${{ steps.prep.outputs.binary_version }} |
| 79 | + context: ./ |
| 80 | + file: ./Dockerfile.webui |
| 81 | + #platforms: linux/amd64,linux/arm64 |
| 82 | + platforms: linux/amd64 |
| 83 | + push: true |
| 84 | + #tags: ${{ steps.prep.outputs.tags }} |
| 85 | + tags: ${{ steps.meta.outputs.tags }} |
| 86 | + labels: ${{ steps.meta.outputs.labels }} |
0 commit comments