Adding Changes that Deploy the Site (tests to follow) #69
Workflow file for this run
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: CI | |
on: | |
push: | |
branches: [ main ] | |
pull_request: | |
branches: [ main ] | |
jobs: | |
unit-tests: | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.8, 3.9] | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Install dependencies | |
run: | | |
python -m pip install --upgrade pip | |
pip install boto3 botocore pytest | |
- name: Run tests | |
run: | | |
pytest tests/unit/test_lambda_functions.py | |
- name: Debug secrets | |
run: | | |
echo "AWS_ACCESS_KEY_ID: ${{ secrets.AWS_ACCESS_KEY_ID }}" | |
echo "AWS_SECRET_ACCESS_KEY: ${{ secrets.AWS_SECRET_ACCESS_KEY }}" | |
build-and-deploy-infra: | |
needs: unit-tests | |
runs-on: ubuntu-latest | |
strategy: | |
matrix: | |
python-version: [3.9] # Ensure this job only runs with Python 3.9 | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: Set up Python | |
uses: actions/setup-python@v2 | |
with: | |
python-version: ${{ matrix.python-version }} | |
- name: Ensure Python 3.9 is on PATH | |
run: | | |
echo "Adding Python 3.9 to PATH" | |
echo "${{ steps.python-setup.outputs.python-location }}/bin" >> $GITHUB_PATH | |
- name: Verify Python version | |
run: | | |
python --version | |
which python | |
- name: Setup SAM CLI | |
uses: aws-actions/setup-sam@v1 | |
- name: Configure AWS credentials | |
uses: aws-actions/configure-aws-credentials@v1 | |
with: | |
aws-access-key-id: ${{ secrets.AWS_ACCESS_KEY_ID }} | |
aws-secret-access-key: ${{ secrets.AWS_SECRET_ACCESS_KEY }} | |
aws-region: eu-west-1 | |
- name: Debug AWS credentials | |
run: | | |
env | grep AWS || true | |
- name: Run sam build | |
run: | | |
sam build | |
- name: Run sam deploy | |
run: | | |
sam deploy --no-confirm-changeset --no-fail-on-empty-changeset | |
deploy-site: | |
needs: build-and-deploy-infra | |
runs-on: ubuntu-latest | |
steps: | |
- name: Checkout code | |
uses: actions/checkout@v2 | |
- name: AWS S3 Sync Github Action | |
uses: sai-sharan/[email protected] | |
with: | |
access_key: ${{ secrets.AWS_ACCESS_KEY }} | |
secret_access_key: ${{ secrets.SECRET_ACCESS_KEY }} | |
region: 'eu-west-1' | |
source: 'resume-site' | |
destination_bucket: 'recreated-website2351' | |
delete: true | |