update yaml #24
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: Squib deploy and test | |
on: | |
push: | |
branches: | |
- main | |
jobs: | |
test: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.10' | |
- name: Install Dependencies | |
run: pip install -r requirements.txt | |
- name: Set DATABASE_URL Environment Variable | |
run: | | |
echo "DATABASE_URL=${{ secrets.DATABASE_URL }}" >> $GITHUB_ENV | |
- name: Run Tests | |
env: | |
SECRET_KEY: ${{ secrets.SECRET_KEY }} | |
run: python manage.py test | |
deploy: | |
needs: test # Wait for the 'test' job to complete before starting deployment | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout Repository | |
uses: actions/checkout@v2 | |
- name: Login to Docker Hub | |
uses: docker/login-action@v1 | |
with: | |
username: ${{ secrets.DOCKER_USERNAME }} | |
password: ${{ secrets.DOCKER_TOKEN }} | |
- name: Build and push Docker image | |
run: | | |
# Adjust the Dockerfile path as needed (e.g., ./squib/Dockerfile) | |
docker build -t ${{ secrets.DOCKER_USERNAME }}/squib . | |
docker push ${{ secrets.DOCKER_USERNAME }}/squib | |
- name: Deploy to Heroku | |
env: | |
HEROKU_API_KEY: ${{ secrets.HEROKU_API_KEY }} | |
HEROKU_APP_NAME: squib | |
run: | | |
heroku container:login | |
heroku container:push web -a $HEROKU_APP_NAME | |
heroku container:release web -a $HEROKU_APP_NAME |