Build #84
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
name: Build | |
on: | |
push: | |
branches: | |
- main | |
paths: | |
- '!**.md' | |
- '!**.rst' | |
- '!**.ipynb' | |
- '!docker-compose-example.yml' | |
- 'behavioral_control/**' | |
- '!behavioral_control/tests/**' | |
- 'Dockerfile.base' | |
- 'Dockerfile' | |
pull_request: | |
paths: | |
- '!**.md' | |
- '!**.rst' | |
- '!**.ipynb' | |
- '!docker-compose-example.yml' | |
- 'behavioral_control/**' | |
- '!behavioral_control/tests/**' | |
- 'Dockerfile.base' | |
- 'Dockerfile' | |
workflow_run: | |
workflows: ["Run Tests"] | |
types: [completed] | |
branches: [main] | |
paths: | |
- '!**.md' | |
- '!**.ipynb' | |
- '!docker-compose-example.yml' | |
- 'behavioral_control/**' | |
- '!behavioral_control/tests/**' | |
- 'Dockerfile.base' | |
- 'Dockerfile' | |
jobs: | |
build: | |
name: Build docker image | |
runs-on: ubuntu-latest | |
steps: | |
- uses: actions/checkout@v2 | |
with: | |
fetch-depth: 2 | |
- name: Git branch name | |
id: git-branch-name | |
uses: EthanSK/git-branch-name-action@v1 | |
- uses: actions/setup-python@v1 | |
with: | |
python-version: 3.9 | |
- name: Only proceed if specified workflows succeeded | |
uses: ahmadnassri/action-workflow-run-wait@v1 | |
- name: Get specific changed files | |
id: changed-files-specific | |
uses: tj-actions/[email protected] | |
with: | |
files: | | |
behavioral_control/requirements.txt | |
Dockerfile.base | |
nginx.default | |
package.json | |
behavioral_control/behavioral_control/static/* | |
- name: Login to DockerHub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKERHUB_USERNAME }} | |
password: ${{ secrets.DOCKERHUB_TOKEN }} | |
- name: If any of the listed files above change, build base image | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
run: | | |
cd behavioral_control | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
npm install | |
cd .. | |
docker build -t ${{ secrets.DOCKERHUB_USERNAME }}/ikuai_behavioral_control-base:latest -f Dockerfile.base . || exit 1 | |
- name: Build and push | |
uses: docker/build-push-action@v2 | |
with: | |
context: . | |
push: false | |
tags: ${{ secrets.DOCKERHUB_USERNAME }}/ikuai_behavioral_control:latest | |
- name: Test new image | |
timeout-minutes: 3 | |
run: | | |
# disable FIRST volume | |
# sed -i 's/volumes:/#volumes:/' docker-compose-example.yml | |
# sed -i 's+C:/tmp/log+#C:/tmp/log+g' docker-compose-example.yml | |
docker-compose -f "docker-compose-example.yml" up -d | |
python -m pip install --upgrade pip | |
pip install requests pytest | |
sleep 15 | |
py.test -vv behavioral_control/tests/image_test.py | |
# docker-compose -f "docker-compose-example.yml" down | |
- name: Push new base image | |
if: steps.changed-files-specific.outputs.any_changed == 'true' | |
run: | | |
if [ ${{ env.GIT_BRANCH_NAME }} == 'main' ] | |
then | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/ikuai_behavioral_control-base:latest | |
fi | |
- name: Push new image | |
run: | | |
if [ ${{ env.GIT_BRANCH_NAME }} == 'main' ] | |
then | |
docker push ${{ secrets.DOCKERHUB_USERNAME }}/ikuai_behavioral_control:latest | |
fi |