Skip to content

Add check for dev containers #12

Add check for dev containers

Add check for dev containers #12

name: Check Dev Containers
on:
push:
branches:
- main
pull_request:
workflow_dispatch:
workflow_call:
concurrency:
group: "${{ github.workflow }}-${{ github.head_ref || github.ref }}"
cancel-in-progress: true
jobs:
container_base:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
filters: |
devcontainer_base:
- '.devcontainer/Dockerfile.base'
- .github/workflows/check-dev-containers.yml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
- name: Cache Docker layers
uses: actions/cache@v3
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build DevContainer Base
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
uses: docker/build-push-action@v5.1.0
with:
context: '.devcontainer/'
file: '.devcontainer/Dockerfile.base'
push: false
container:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4.1.1
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
filters: |
devcontainer:
- '.devcontainer/Dockerfile'
- .github/workflows/check-dev-containers.yml
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
- name: Cache Docker layers
uses: actions/cache@v3
if: ${{ steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build DevContainer
if: ${{ steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
uses: docker/build-push-action@v5.1.0
with:
context: '.devcontainer/'
file: '.devcontainer/Dockerfile'
push: false
container_chained:
runs-on: ubuntu-latest
services:
registry:
image: registry:2
ports:
- 5000:5000
steps:
- uses: actions/checkout@v4.1.1
- uses: dorny/paths-filter@v2.11.1
id: filter
with:
filters: |
devcontainer_base:
- '.devcontainer/Dockerfile.base'
- .github/workflows/check-dev-containers.yml
devcontainer:
- '.devcontainer/Dockerfile'
- .github/workflows/check-dev-containers.yml
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
with:
driver-opts: network=host
- name: Cache Docker layers
uses: actions/cache@v3
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx
- name: Build DevContainer Base
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
uses: docker/build-push-action@v5.1.0
with:
context: '.devcontainer/'
file: '.devcontainer/Dockerfile.base'
push: true
tags: localhost:5000/eclipse-ankaios/devcontainer-base:dev
- name: Change image reference
if: ${{ steps.filter.outputs.devcontainer_base == 'true' }}
run: |
sed -i "s#ghcr.io/eclipse-ankaios/devcontainer-base:.*#localhost:5000/eclipse-ankaios/devcontainer-base:dev#" .devcontainer/Dockerfile
cat .devcontainer/Dockerfile
- name: Build DevContainer
if: ${{ steps.filter.outputs.devcontainer_base == 'true' || steps.filter.outputs.devcontainer == 'true' || github.ref_name == 'main' || github.ref_type == 'tag'}}
uses: docker/build-push-action@v5.1.0
with:
context: '.devcontainer/'
file: '.devcontainer/Dockerfile'
push: false