Skip to content

Workflow file for this run

name: C++ Build and Run (Сборка и запуск проекта)
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build:
name: Build Docker Image
runs-on: ubuntu-latest
steps:
- name: Checkout repository
uses: actions/checkout@v4
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
id: cache-docker-layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-docker-${{ github.sha }}
restore-keys: |
${{ runner.os }}-docker-
- name: Build Docker image with Docker Compose
run: |
docker compose build bmstu
docker compose up bmstu
# Save the image as a tarball
docker save bmstu_cpp_course-bmstu:latest -o cpp_course_image.tar
- name: Upload Docker image tarball
uses: actions/upload-artifact@v3
with:
name: cpp_course-image
path: cpp_course_image.tar
- name: Save Docker layer cache
if: always()
uses: actions/upload-artifact@v3
with:
name: docker-layer-cache
path: /tmp/.buildx-cache
run-script:
name: Run run.sh Script
runs-on: ubuntu-latest
needs: build
steps:
- name: Download Docker image tarball
uses: actions/download-artifact@v3
with:
name: cpp_course-image
path: ./artifacts
- name: Load Docker image
run: |
docker load -i ./artifacts/cpp_course_image.tar
- name: Run run.sh Script inside Docker Container
run: |
docker run --rm -v ${{ github.workspace }}:/cppcourse bmstu_cpp_course-bmstu:latest bash -c "cd /cppcourse && ls -la && cd .. && ./cppcourse/docker/run_tasks/run.sh"