implemented blue green deployment for k8s deployments using terraform #79
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" | |
pull_request: | |
branches: | |
- "main" | |
permissions: | |
contents: read | |
pull-requests: read | |
concurrency: | |
group: "${{ github.workflow }} @ ${{ github.event.pull_request.head.label || github.head_ref || github.ref }}" | |
cancel-in-progress: true | |
jobs: | |
skip-check: | |
runs-on: ubuntu-latest | |
permissions: | |
actions: write | |
contents: read | |
outputs: | |
should_skip: ${{ steps.skip_check.outputs.should_skip }} | |
steps: | |
- id: skip_check | |
uses: fkirc/skip-duplicate-actions@v5.3.0 | |
with: | |
skip_after_successful_duplicate: "true" | |
test: | |
runs-on: ubuntu-latest | |
needs: | |
- skip-check | |
env: | |
COMPOSE_FILE: docker-compose.yml | |
if: ${{ needs.pre_job.outputs.should_skip != 'true' }} | |
strategy: | |
matrix: | |
python-version: [3.7, 3.8, 3.9] | |
steps: | |
# Checkout the latest code from the repo | |
- name: Checkout repo | |
uses: actions/checkout@v2 | |
# Setup which version of Python to use | |
- name: Set Up Python ${{ matrix.python-version }} | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
# Display the Python version being used | |
- name: Display Python version | |
run: python -c "import sys; print(sys.version)" | |
- name: Set Env variables | |
run: | | |
touch .env | |
echo "COINBASE_API_KEY=${{secrets.COINBASE_API_KEY}}" >> .env | |
echo "COINBASE_SECRET_KEY=${{secrets.COINBASE_SECRET_KEY}}" >> .env | |
echo "FAUNA_SECRET_KEY=${{secrets.FAUNA_SECRET_KEY}}" >> .env | |
echo "ENV=${{secrets.ENV}}" >> .env | |
echo "AWS_SECRET_KEY=${{secrets.AWS_SECRET_KEY}}" >> .env | |
echo "AWS_ID=${{secrets.AWS_ID}}" >> .env | |
echo "REDIS_HOST=${{secrets.REDIS_HOST}}" >> .env | |
echo "REDIS_PORT=${{secrets.REDIS_PORT}}" >> .env | |
echo "REDIS_PASSWORD=${{secrets.REDIS_PASSWORD}}" >> .env | |
echo "REDIS_USERNAME=${{secrets.REDIS_USERNAME}}" >> .env | |
cat .env | |
- name: Pull images | |
run: docker-compose pull | |
- name: Build images and install dependencies | |
run: docker-compose build | |
- name: Run containers | |
run: docker-compose up -d | |
- name: Run tests | |
run: docker-compose run web coverage run -m pytest | |
# - name: Install coverage and pytest | |
# run: | | |
# python -m pip install --upgrade pip | |
# pip install -r requirements.txt | |
# # Run the tests. I'm using pytest and coverage and the file is in the tests directory. | |
# - name: Run tests | |
# run: coverage run -m pytest | |
- name: Get Code Coverage | |
uses: codecov/codecov-action@v2 | |
with: | |
token: ${{ secrets.CODECOV_TOKEN }} |