Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/publish docker #148

Merged
merged 4 commits into from
Mar 7, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 14 additions & 5 deletions .github/workflows/dockerimage.yml → .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,7 @@ on:
- cron: "50 7 * * *"

jobs:
# To avoid uploading the Docker image to a registry yet
# the image is built here & immediately used to test all exercises in.
build_image_and_test:
build-examples:
name: Build ${{ matrix.project.name }}
runs-on: ubuntu-latest
strategy:
Expand All @@ -41,10 +39,21 @@ jobs:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Verify Changed files
uses: tj-actions/verify-changed-files@v13
id: dockerfile-changed
with:
files: .devcontainer/Dockerfile

- name: Build Docker image
run: docker image build --tag esp --file .devcontainer/Dockerfile .
if: steps.dockerfile-changed.outputs.files_changed == 'true'
run: docker image build --tag espressif/rust-std-training --file .devcontainer/Dockerfile .

- name: Pull Docker image
if: steps.dockerfile-changed.outputs.files_changed == 'false'
run: docker image pull espressif/rust-std-training

- name: Test code example in Docker image
run: |
docker run --mount type=bind,source="$(pwd)",target=/workspace,consistency=cached \
--rm esp:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }}
--rm espressif/rust-std-training:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }}
3 changes: 1 addition & 2 deletions .github/workflows/book.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
---

name: Book CI
on: [push, pull_request]

env:
MDBOOK_VERSION: "0.4.14"
MDBOOK_VERSION: "0.4.28"

jobs:
build:
Expand Down
75 changes: 75 additions & 0 deletions .github/workflows/docker_image.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
---
name: Publish Docker Image

on:
push:
branches:
- main
paths:
- ".devcontainer/Dockerfile"
workflow_dispatch:

jobs:
build-examples:
name: Build ${{ matrix.project.name }}
runs-on: ubuntu-latest
strategy:
fail-fast: false
matrix:
project:
- name: "button-interrupt"
path: "advanced/button-interrupt"
- name: "i2c-driver"
path: "advanced/i2c-driver"
- name: "i2c-sensor-reading"
path: "advanced/i2c-sensor-reading"
- name: "hardware-check"
path: "intro/hardware-check"
- name: "http-client"
path: "intro/http-client"
- name: "http-server"
path: "intro/http-server"
- name: "mqtt"
path: "intro/mqtt/exercise"
- name: "mqtt - host client"
path: "intro/mqtt/host-client"
steps:
- name: Checkout the repository
uses: actions/checkout@v3

- name: Build Docker image
run: docker image build --tag espressif/rust-std-training --file .devcontainer/Dockerfile .

- name: Test code example in Docker image
run: |
docker run --mount type=bind,source="$(pwd)",target=/workspace,consistency=cached \
--rm espressif/rust-std-training:latest /bin/bash /workspace/.devcontainer/test.sh ${{ matrix.project.path }}

publish-container:
name: Update container image on DockerHub
needs: build-examples
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v3

- name: Set up QEMU
uses: docker/setup-qemu-action@v2

- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2

- name: Login to DockerHub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_USERNAME }}
password: ${{ secrets.DOCKER_TOKEN }}

- name: Build and push container
uses: docker/build-push-action@v4
with:
context: .
file: .devcontainer/Dockerfile
tags: espressif/rust-std-training:latest
push: true
platforms: linux/amd64, linux/arm64