diff --git a/.github/workflows/build-images-on-commit.yml b/.github/workflows/build-images-on-commit.yml new file mode 100644 index 0000000..bb547f2 --- /dev/null +++ b/.github/workflows/build-images-on-commit.yml @@ -0,0 +1,17 @@ +name: Build and publish dev container images + +on: + push: + branches: [ main ] + paths: + - 'src/loaders/**' + - 'src/services/**' + - '.version' + workflow_dispatch: + +jobs: + build: + uses: ./.github/workflows/reusable-build-container-images.yml + with: + push: true + release_stream: dev diff --git a/.github/workflows/check.yml b/.github/workflows/check.yml new file mode 100644 index 0000000..94fd488 --- /dev/null +++ b/.github/workflows/check.yml @@ -0,0 +1,16 @@ +name: Check container builds + +on: + pull_request_target: + branches: [ main ] + paths: + - 'src/loaders/**' + - 'src/services/**' + - '.version' + +jobs: + build: + uses: ./.github/workflows/reusable-build-container-images.yml + with: + push: false + release_stream: dev diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml new file mode 100644 index 0000000..debcd2e --- /dev/null +++ b/.github/workflows/release.yml @@ -0,0 +1,13 @@ +name: Build and publish release container images + +on: + release: + types: [published] + +jobs: + build: + uses: ./.github/workflows/reusable-build-container-images.yml + with: + push: true + release_stream: latest + secrets: inherit \ No newline at end of file diff --git a/.github/workflows/reusable-build-container-images.yml b/.github/workflows/reusable-build-container-images.yml new file mode 100644 index 0000000..c8c8901 --- /dev/null +++ b/.github/workflows/reusable-build-container-images.yml @@ -0,0 +1,60 @@ +on: + workflow_call: + inputs: + push: + description: Set to true to push images to registries + default: false + required: false + type: boolean + release_stream: + type: string + description: Set the release stream (latest, dev, ...) + required: false + default: dev + registry_ghcr: + description: github container registry + default: 'ghcr.io/cisco-open/app-simulator' + required: false + type: string +jobs: + build: + runs-on: ubuntu-24.04 + strategy: + matrix: + image: + - context: ./src/loaders/curl + name: loaders-curl + + steps: + - name: Checkout + uses: actions/checkout@v4.2.2 + - name: Bump version + # Only bump the version if the release stream is not 'latest' + # This way we make sure that released versions are fixed to their version + # and that 'dev' or other non stable releases do not overwrite. + if: ${{ inputs.release_stream != 'latest' }} + run: ./scripts/bumpversion.sh --patch + - name: Read version from .version file + id: version + run: echo "::set-output name=version::$(cat .version)" + - name: Log into GitHub Container Registry + uses: docker/login-action@v3 + with: + registry: ghcr.io + username: ${{ github.repository_owner }} + password: ${{ secrets.GITHUB_TOKEN }} + - name: Set up QEMU + uses: docker/setup-qemu-action@v3 + with: + platforms: arm64, amd64 + - name: Set up Docker Buildx + uses: docker/setup-buildx-action@v3 + - name: Build and push images + uses: docker/build-push-action@v6 + with: + context: ${{ matrix.image.context }} + platforms: linux/amd64,linux/arm64 + push: ${{ inputs.push }} + tags: | + ${{ inputs.registry_ghcr }}-${{ matrix.image.name }}:${{ steps.version.outputs.version }} + ${{ inputs.registry_ghcr }}-${{ matrix.image.name }}:${{ inputs.release_stream }}