Skip to content

Commit

Permalink
Make actions use docker compose file
Browse files Browse the repository at this point in the history
  • Loading branch information
LukeShirnia committed Apr 26, 2024
1 parent 83a884c commit 7fcb04f
Showing 1 changed file with 45 additions and 43 deletions.
88 changes: 45 additions & 43 deletions .github/workflows/pytest.yml
Original file line number Diff line number Diff line change
Expand Up @@ -10,49 +10,51 @@ env:

jobs:

build_and_push:
runs-on: ubuntu-latest
steps:
- name: Checkout code
uses: actions/checkout@v3

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

- name: Login to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

- name: Pull Docker images (if exists)
run: |
docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do
base_image_name=$(echo $image | awk -F: '{print $1}')
version_tag=$(echo $image | awk -F: '{print $2}')
existing_tag="${{ env.REPOSITORY }}:${base_image_name#*/}"
echo "Trying to pull existing image $existing_tag"
docker pull $existing_tag || true # Continue even if pull fails
done
- name: Build Docker images
run: |
docker-compose build --pull
- name: Push Docker images
run: |
docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do
echo "Processing image: $image"
base_image_name=$(echo $image | awk -F: '{print $1}')
version_tag=$(echo $image | awk -F: '{print $2}')
new_tag="${{ env.REPOSITORY }}:${base_image_name#*/}"
echo "Tagging image $image as $new_tag"
docker tag $image $new_tag
docker push $new_tag
done
# Lets not build and push images every time. This can be done manually. Leaving here for reference.

# build_and_push:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout code
# uses: actions/checkout@v3

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

# - name: Login to Docker Hub
# uses: docker/login-action@v2
# with:
# username: ${{ secrets.DOCKER_HUB_USERNAME }}
# password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}

# - name: Pull Docker images (if exists)
# run: |
# docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do
# base_image_name=$(echo $image | awk -F: '{print $1}')
# version_tag=$(echo $image | awk -F: '{print $2}')
# existing_tag="${{ env.REPOSITORY }}:${base_image_name#*/}"
# echo "Trying to pull existing image $existing_tag"
# docker pull $existing_tag || true # Continue even if pull fails
# done

# - name: Build Docker images
# run: |
# docker-compose build --pull

# - name: Push Docker images
# run: |
# docker-compose config | grep 'image:' | awk '{print $2}' | while read image; do
# echo "Processing image: $image"
# base_image_name=$(echo $image | awk -F: '{print $1}')
# version_tag=$(echo $image | awk -F: '{print $2}')
# new_tag="${{ env.REPOSITORY }}:${base_image_name#*/}"
# echo "Tagging image $image as $new_tag"
# docker tag $image $new_tag
# docker push $new_tag
# done

test-python-versions:
needs: build_and_push
# needs: build_and_push
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -69,7 +71,7 @@ jobs:
pytest -v --ignore=tests/test_system.py
test-systems:
needs: build_and_push
# needs: build_and_push
runs-on: ubuntu-latest
strategy:
matrix:
Expand All @@ -81,7 +83,7 @@ jobs:
- name: Setup test command
id: setup
run: |
if [ "${{ matrix.distro }}" == "osx-pytest" ]; then
if [ "${{ matrix.distro }}" == " ${{ env.REPOSITORY }}:osx-pytest" ]; then
echo "::set-output name=command::python -m pytest"
else
echo "::set-output name=command::pytest"
Expand Down

0 comments on commit 7fcb04f

Please sign in to comment.