Skip to content
This repository has been archived by the owner on Oct 13, 2024. It is now read-only.

fix: Add docker-compose and update image tagging #25

fix: Add docker-compose and update image tagging

fix: Add docker-compose and update image tagging #25

name: Build and Test Streamlit App
on:
push:
branches:
- main
pull_request:
branches:
- main
jobs:
build_run_test:
runs-on: ubuntu-latest
permissions:
contents: read
packages: write
steps:
- name: Checkout code
uses: actions/checkout@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v2
- name: Cache Docker layers
uses: actions/cache@v3
with:
path: /tmp/.buildx-cache
key: ${{ runner.os }}-buildx-${{ github.sha }}
restore-keys: |
${{ runner.os }}-buildx-
- name: Build Docker image
run: docker build -t my-streamlit-app .
- name: Run Streamlit app
run: |
docker run -d --name streamlit-container -p 8505:8505 my-streamlit-app
sleep 10 # Give the container some time to start
- name: Check container status
run: docker inspect streamlit-container
- name: Run Robot Framework tests
run: |
pip install git+https://github.com/robotframework/SeleniumLibrary.git
wget https://github.com/mozilla/geckodriver/releases/download/v0.34.0/geckodriver-v0.34.0-linux64.tar.gz
tar -xvzf geckodriver*
chmod +x geckodriver
sudo mv geckodriver /usr/local/bin/
robot tests/
- name: Downcase REPO
run: |
echo "REPO=${GITHUB_REPOSITORY,,}" >>${GITHUB_ENV}
- name: Login to GitHub Container Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: '${{ github.repository_owner }}'
password: '${{ secrets.GITHUB_TOKEN }}'
- name: Push image to GitHub Container Registry
run: |
docker tag my-streamlit-app:latest ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:v1.${{ github.run_number }}
docker tag my-streamlit-app:latest ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:latest
docker push ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:v1.${{ github.run_number }}
docker push ghcr.io/${{ github.repository_owner }}/${{ env.REPO }}:latest
- name: Stop and remove container
if: always()
run: docker rm -f streamlit-container