Skip to content

Commit

Permalink
git branch fix
Browse files Browse the repository at this point in the history
  • Loading branch information
Michele Fabbri committed Apr 12, 2022
1 parent 5ecc1db commit 9352dcb
Showing 1 changed file with 54 additions and 14 deletions.
68 changes: 54 additions & 14 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ on:
- dev

jobs:
run_tests:
run_jobs:
runs-on: ubuntu-latest
services:
postgres:
image: postgres
image: postgres:13
env:
POSTGRES_PASSWORD: postgres
POSTGRES_USER: postgres
Expand All @@ -28,25 +28,28 @@ jobs:
- 5432:5432
steps:
- uses: actions/checkout@v2

- name: Build database
run: psql -c "CREATE DATABASE githubactions;" -U postgres -h localhost -p 5432
env:
PGPASSWORD: postgres

- name: Set up Python
uses: actions/setup-python@v2
with:
python-version: '3.8'
- name: Install dependecies
- name: Install Python dependecies
run: |
python -m pip install --upgrade pip
pip install -r requirements.txt
pip install coverage coveralls
env:
PIP_USE_MIRRORS: true

- name: Run tests
run: |
sudo touch /var/log/alyx.log; sudo chmod 776 /var/log/alyx.log
sudo touch /var/log/alyx_json.log; sudo chmod 776 /var/log/alyx_json.log
sudo touch /var/log/alyx.log; sudo chmod 666 /var/log/alyx.log
sudo touch /var/log/alyx_json.log; sudo chmod 666 /var/log/alyx_json.log
cd alyx
mv alyx/settings_ci.py alyx/settings.py
coverage run manage.py test -n
Expand All @@ -55,27 +58,64 @@ jobs:
DJANGO_SETTINGS_MODULE: alyx.settings
PYTHONPATH: $HOME/builds/cortexlab/alyx
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}

- name: Flake
run: |
cd alyx
flake8 .
build:
runs-on: ubuntu-latest
if: ${{ github.ref == 'refs/heads/master' }}
steps:
- name: Checkout
uses: actions/checkout@v2
- name: Login to Docker Hub
- name: Generate pip freeze requirements.txt
run: |
pip freeze > requirements_frozen.txt
echo ">>> Contents of requirements_frozen.txt <<<"
cat requirements_frozen.txt
- name: Setup git
run: |
git config user.name "GitHub Actions"
git config user.email "<>"
- name: Commit requirements_frozen.txt to repo
run: |
git add requirements_frozen.txt
git commit -m "GitHub Actions generated requirements_frozen.txt"
git push origin master
- name: Copy files to S3
shell: bash
env:
aws_key_id: ${{ secrets.AWS_ACCESS_KEY_ID }}
aws_secret_access_key: ${{ secrets.AWS_SECRET_KEY_ID }}
aws_s3_bucket: ${{ secrets.AWS_S3BUCKET_NAME }}
aws_region: ${{ secrets.AWS_REGION }}
run: |
sudo apt-get update && sudo apt-get -y install awscli
aws configure set aws_access_key_id $aws_key_id
aws configure set aws_secret_access_key $aws_secret_access_key
aws configure set default.region $aws_region
aws s3 cp requirements_frozen.txt s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/000-default-conf-alyx-dev s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/000-default-conf-alyx-prod s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/000-default-conf-openalyx s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/apache-conf-alyx-dev s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/apache-conf-alyx-prod s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/apache-conf-openalyx s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/cloudwatch_config.json-alyx-dev s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/cloudwatch_config.json-alyx-prod s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/cloudwatch_config.json-openalyx s3://$aws_s3_bucket/github_actions/
aws s3 cp scripts/deployment_examples/alyx-docker/Dockerfile.ibl s3://$aws_s3_bucket/github_actions/
- name: Configure Docker login
if: ${{ github.ref == 'refs/heads/docker' }}
uses: docker/login-action@v1
with:
username: ${{ secrets.DOCKER_HUB_USERNAME }}
password: ${{ secrets.DOCKER_HUB_ACCESS_TOKEN }}
- name: Set up Docker Buildx
if: ${{ github.ref == 'refs/heads/docker' }}
uses: docker/setup-buildx-action@v1
- name: Build and push
- name: Build and push Docker base image
if: ${{ github.ref == 'refs/heads/docker' }}
uses: docker/build-push-action@v2
with:
context: .
file: ./scripts/deployment_examples/alyx-docker/Dockerfile.base
push: true
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/alyx:base
tags: ${{ secrets.DOCKER_HUB_USERNAME }}/alyx:base

0 comments on commit 9352dcb

Please sign in to comment.