Skip to content

Commit

Permalink
[actions] Build docker container when Dockerfile are modified
Browse files Browse the repository at this point in the history
When any Dockerfile is modified, we should rebuild the container before running the CI.
Failing to do so, we would need to:
1) land the docker file change in order to incorporate the change
2) land the charge that uses this new dockerfile change

This is cumbersome and it is hard to make sure that changes to the dockerfile are indeed correct.

This change conditionally pull the pre-built image if no dockerfile change happened. Otherwise
it reuses the "build_container" action to build the image.

This commit should confirm that we indeed pull when no dockerfile are changed.
A subsequent commit will modify a Dockerfile and confirm that in that case, we indeed build the container.
  • Loading branch information
chantra committed Sep 9, 2022
1 parent 83cf8b1 commit 75e5e26
Showing 1 changed file with 34 additions and 14 deletions.
48 changes: 34 additions & 14 deletions .github/workflows/bcc-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,19 +30,29 @@ jobs:
RW_ENGINE_ENABLED: ON
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
docker:
- 'docker/build/**'
- name: System info
run: |
uname -a
ip addr
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull and tag docker container
- name: Pull docker container
if: steps.changes.outputs.docker == 'false'
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }}
- name: Build docker container
if: steps.changes.outputs.docker == 'true'
uses: ./.github/actions/build-container
with:
os_distro: ${{ matrix.os.distro }}
os_version: ${{ matrix.os.version }}
os_nick: ${{ matrix.os.nick }}
- name: Tag docker container
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }} bcc-docker
- name: Run bcc build
env: ${{ matrix.env }}
Expand Down Expand Up @@ -121,19 +131,29 @@ jobs:
PYTHON_TEST_LOGFILE: critical.log
steps:
- uses: actions/checkout@v2
- uses: dorny/paths-filter@v2
id: changes
with:
filters: |
docker:
- 'docker/build/**'
- name: System info
run: |
uname -a
ip addr
- name: Log into registry ${{ env.REGISTRY }}
uses: docker/login-action@v2
with:
registry: ${{ env.REGISTRY }}
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}
- name: Pull and tag docker container
- name: Pull docker container
if: steps.changes.outputs.docker == 'false'
run: |
docker pull ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }}
- name: Build docker container
if: steps.changes.outputs.docker == 'true'
uses: ./.github/actions/build-container
with:
os_distro: ${{ matrix.os.distro }}
os_version: ${{ matrix.os.version }}
os_nick: ${{ matrix.os.nick }}
- name: Tag docker container
run: |
docker tag ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }}:${{ matrix.os.distro }}-${{ matrix.os.version }} bcc-docker
- name: Run bcc build
env: ${{ matrix.env }}
Expand Down

0 comments on commit 75e5e26

Please sign in to comment.