Update README.md #196
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: 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 | |
# docker image deployment : for future | |
#- name: Deploy Docker image to production | |
# run: docker run -d -p 80:80 --name job_market_container 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 |