PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Sunday, October 9, 2022

[FIXED] How can I wait for the container to be healthy in GitHub action?

 October 09, 2022     continuous-integration, docker, github-actions     No comments   

Issue

I am using GitHub action to do some automation test and my application was developed in docker.

name: Docker Image CI

on:
  push:
    branches: [ master]
  pull_request:
    branches: [ master]

jobs:

  build:

    runs-on: ubuntu-latest

    steps:
    - uses: actions/checkout@v2
    - name: Build the Docker image
      run: docker-compose build

    - name: up mysql and apache container runs
      run: docker-compose up -d 

    - name: install dependencies
      run: docker exec  myapp php composer.phar install
  
    - name: show running container
      run: docker ps 


    - name: run unit test
      run: docker exec  myapp ./vendor/bin/phpunit 

At the step 'show running container', I can see that all the containers are running but for the MySQL, the status is (health: starting). Thus, my unit test cases all failed as it requires a connection to MySQL. So may I know if there is a way to start the unit case only when the MySQL container's status is healthy?


Solution

I would like to offer a solution, not a smart one but it requires minimum configuration and ready to go, just use the GitHub Action for Sleeping.

jobs:
  deploy:
    runs-on: ubuntu-latest
    steps:
    - name: Sleep for 30 seconds
      uses: jakejarvis/wait-action@master
      with:
        time: '30s'

Assumption: your Mysql server will be up and running in 30s.



Answered By - sfsf9797
Answer Checked By - Candace Johnson (PHPFixing Volunteer)
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing