enviornment variable #154
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: Continuous Integration/Continuous Deployment | |
on: | |
push: | |
branches: | |
- main | |
pull_request: | |
branches: | |
- main | |
jobs: | |
build: | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: '3.x' | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install -r requirements.txt | |
- name: Set up Docker Compose | |
run: | | |
sudo apt-get update | |
sudo apt-get install -y docker-compose | |
#- name: Start Elasticsearch | |
# run: | | |
# docker-compose -f path/to/your/docker-compose.yaml up -d elasticsearch | |
#- name: Load data into Elasticsearch | |
# run: python scripts/database/db_connection.py | |
#- name: Create FastAPI application | |
# run: | | |
# # Replace this command with the script/command to create the FastAPI application | |
# python api.py | |
- name: Build Docker image | |
run: | | |
docker build -t arunp77/job_market:latest . | |
- name: Push Docker image | |
run: | | |
echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
docker push arunp77/job_market:latest | |
deploy: | |
needs: build | |
runs-on: ubuntu-latest | |
if: github.event_name == 'push' && github.ref == 'refs/heads/main' # Only deploy on push to main branch | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Docker Buildx | |
uses: docker/setup-buildx-action@v1 | |
- name: Configure Docker credentials | |
run: echo "${{ secrets.DOCKER_PASSWORD }}" | docker login -u "${{ secrets.DOCKER_USERNAME }}" --password-stdin | |
- name: Pull Docker image | |
run: docker pull arunp77/job_market:latest | |
- name: Deploy Docker image to production | |
run: docker run -d -p 80:80 arunp77/job_market:latest | |
- name: Store environment variables | |
run: | | |
echo "DOCKER_PASSWORD=${{ secrets.DOCKER_PASSWORD }}" >> $HOME/.env | |
echo "DOCKER_USERNAME=${{ secrets.DOCKER_USERNAME }}" >> $HOME/.env |