Skip to content

ci

ci #14

Workflow file for this run

name: ci
on:
push:
workflow_dispatch:
env:
FIO_FACTORY: lmp-demo
FIO_REGISTRY: hub.foundries.io
DOCKER_IMAGES_DIR: docker
COMPOSE_APP_DIR: compose/home-gateway
COMPOSE_APP_NAME: home-gateway
TUF_TARGET_TAG: ${{ github.ref_name }}
jobs:
build-images:
runs-on: ubuntu-latest
strategy:
matrix:
docker_dir: [ha-plugin, ha-app]
outputs:
image_tag: ${{ steps.tag.outputs.short_sha }}
image_uri_ha-plugin: ${{ steps.pinning.outputs.image_uri_ha-plugin }}
image_uri_ha-app: ${{ steps.pinning.outputs.image_uri_ha-app }}
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Set short git commit SHA
id: tag
run: |
calculatedSha=$(git rev-parse --short ${{ github.sha }})
echo "short_sha=$calculatedSha" >> $GITHUB_OUTPUT
-
name: Set up QEMU
uses: docker/setup-qemu-action@v2
-
name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
-
name: Login to Foundries Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.FIO_REGISTRY }}
username: "doesntmatter"
password: ${{ secrets.FIO_TOKEN }}
-
name: Build and push docker image
id: docker_build
uses: docker/build-push-action@v3
with:
outputs: type=registry,oci-mediatypes=false
provenance: false
platforms: linux/amd64,linux/arm64
context: "{{ defaultContext }}:${{ env.DOCKER_IMAGES_DIR }}/${{ matrix.docker_dir }}"
tags: |
${{ env.FIO_REGISTRY }}/${{ env.FIO_FACTORY }}/${{ matrix.docker_dir }}:${{ steps.tag.outputs.short_sha }}
${{ env.FIO_REGISTRY }}/${{ env.FIO_FACTORY }}/${{ matrix.docker_dir }}:latest
-
name: Save image URI
id: pinning
run: |
uri=${{ env.FIO_REGISTRY }}/${{ env.FIO_FACTORY }}/${{ matrix.docker_dir }}@${{ steps.docker_build.outputs.digest }}
echo "image_uri_${{matrix.docker_dir}}=$uri" >> $GITHUB_OUTPUT
build-app:
needs: build-images
runs-on: ubuntu-latest
container:
image: foundries/lmp-app-tools
steps:
-
name: Checkout
uses: actions/checkout@v3
-
name: Login to Foundries Container Registry
uses: docker/login-action@v2
with:
registry: ${{ env.FIO_REGISTRY }}
username: "doesntmatter"
password: ${{ secrets.FIO_TOKEN }}
-
name: Build and push Fio App
id: app
working-directory: ${{ env.COMPOSE_APP_DIR }}
run: |
compose-publish -d app.hash --pinned-images ${{needs.build-images.outputs.image_uri_ha-plugin}},${{needs.build-images.outputs.image_uri_ha-app}} ${{ env.FIO_REGISTRY }}/${{ env.FIO_FACTORY }}/${{ env.COMPOSE_APP_NAME }}:${{ needs.build-images.outputs.image_tag }} amd64,arm64
uri="${{ env.FIO_REGISTRY }}/${{ env.FIO_FACTORY }}/${{ env.COMPOSE_APP_NAME }}@$(cat app.hash)"
echo "app_uri=$uri" >> $GITHUB_OUTPUT
-
name: Compose and post Fio Targets
run: fioctl targets add --type app --tags ${{ env.TUF_TARGET_TAG }} --src-tag ${{ env.TUF_TARGET_TAG }} ${{ steps.app.outputs.app_uri }} -t ${{ secrets.FIO_TOKEN }} -f ${{ env.FIO_FACTORY }}