Skip to content

run the image

run the image #17

Workflow file for this run

name: Build and Run Docker Image
on:
push:
branches:
- 'ci' # Trigger on push to release branches
jobs:
build_and_run:
runs-on: ubuntu-latest # Use a GitHub-hosted runner
steps:
- name: Checkout Code
uses: actions/checkout@v3
- name: Image name
run: echo DOCKER_IMAGE_NAME=$(echo ${{ github.event.repository.name }} | tr '[A-Z]' '[a-z]') | tee -a $GITHUB_ENV
- name: Set Up Docker Build
env:
RELEASE_VERSION: ${{ github.ref_name }} # Extract version from branch name
run: |
echo "Building release version $RELEASE_VERSION"
echo "RELEASE_VERSION=$RELEASE_VERSION" | tee -a $GITHUB_ENV
- name: Build Docker Image
run: |
docker build . --file Dockerfile --tag $DOCKER_IMAGE_NAME:$RELEASE_VERSION
- name: Run Docker Container
run: |
# docker images
docker run -d --name my_running_container $DOCKER_IMAGE_NAME:$RELEASE_VERSION
# - name: Clean Up
# run: |
# docker rm -f my_running_container || true
# docker rmi $DOCKER_IMAGE_NAME:$RELEASE_VERSION || true