add build date #56
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: Pipeline | |
on: | |
push: | |
branches: | |
- test | |
- main | |
workflow_dispatch: # Allows you to run this workflow manually from the Actions tab | |
permissions: | |
id-token: write # This is required for requesting the JWT | |
contents: read # This is required for actions/checkout | |
env: | |
AWS_REGION: us-east-1 | |
ENVIRONMENT: ${{ github.ref_name == 'main' && 'prod' || github.ref_name == 'test' && 'test' }} | |
jobs: | |
unit-test: | |
runs-on: ubuntu-latest | |
if: github.ref_name == 'test' | |
defaults: | |
run: | |
working-directory: function | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
# Install dependencies | |
- name: Set up Python | |
run: uv python install | |
- name: Install the project | |
run: uv sync --group test | |
# Run unit tests | |
# - name: Run tests | |
# run: uv run pytest -s . | |
deploy: | |
runs-on: ubuntu-latest | |
needs: unit-test | |
defaults: | |
run: | |
working-directory: terraform | |
steps: | |
- uses: actions/checkout@v3 | |
- name: Install uv | |
uses: astral-sh/setup-uv@v5 | |
with: | |
enable-cache: true | |
- name: Configure AWS Credentials | |
uses: aws-actions/configure-aws-credentials@v4 | |
with: | |
audience: sts.amazonaws.com | |
aws-region: ${{ env.AWS_REGION }} | |
role-to-assume: arn:aws:iam::639269844451:role/github-actions | |
role-session-name: testing-deployment | |
- name: Setup Terraform | |
uses: hashicorp/setup-terraform@v3 | |
- name: Terraform Init | |
run: terraform init | |
- name: Select/Create Terraform Workspace | |
run: | | |
terraform workspace list || echo "Workspace list unavailable" | |
terraform workspace select ${{ env.ENVIRONMENT }} || terraform workspace new ${{ env.ENVIRONMENT }} | |
- name: Terraform Plan | |
run: terraform plan | |
- name: Terraform Apply | |
run: terraform apply -auto-approve |